-
Notifications
You must be signed in to change notification settings - Fork 560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[3.x] Blade x components instead of custom directive #1360
[3.x] Blade x components instead of custom directive #1360
Conversation
public $item; | ||
public $label; | ||
public $form_fields; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking of something to add here like:
getVuexStoreData
We could also go further and do something like:
getVueComponent
getVueComponentProps
and always render the same view file.
@ifox so this is a working example with the checkbox implementation. What do you think of the comments I left? |
I think I can fix the L7 compatibility, but 6 is out of the question, therefor this will be a 3.x feature. Maybe even document it as the suggested way? |
Updated this to no longer need the $form, making it work just like this:
|
@ifox , All green! It does only work on Laravel 8 because 7 does not implement the required methods yet. |
|
Fixed the in-modal and block editor fields, simply forgot to implement this. |
I am using this in a project now and will check for issues as I progress. |
Hey @ifox, I think this is done now. Could you have a look? Cheers. |
All form fields are not implemented in the formbuilder: class BlogController extends BaseModuleController
{
protected $moduleName = 'blogs';
protected $indexOptions = [
];
public function getForm(Model $model): Form
{
return Form::make([
Wysiwyg::make()
->allowSource()
->maxLength(100)
->name('wysiwyg'),
Select::make()
->placeholder('test')
->options(
Options::make([
Option::make('brussels', 'Brussels'),
Option::make('paris', 'Paris'),
Option::make('amsterdam', 'Amsterdam'),
])
)
->name('city'),
Repeater::make()
->type('categories')
->buttonAsLink()
->disableReorder(),
Radios::make()
->inline()
->columns(2)
->border()
->options(
Options::make([
Option::make('brussels', 'Brussels'),
Option::make('paris', 'Paris'),
Option::make('amsterdam', 'Amsterdam'),
])
)
->name('city'),
MultiSelect::make()
->unpack()
->options(
Options::make([
Option::make('brussels', 'Brussels'),
Option::make('paris', 'Paris'),
Option::make('amsterdam', 'Amsterdam'),
])
)
->name('city'),
Medias::make()
->withoutAddInfo()
->name('cover'),
Map::make()
->name('map')
->openMap(),
Files::make()
->name('files')
->itemLabel('document'),
DatePicker::make()
->name('Date')
->placeholder('HH:II')
->hourIncrement(2)
->minuteIncrement(5)
->timeOnly(),
Input::make()
->name('description')
->note('Note')
->type(Input::TYPE_TEXTAREA)
->rows(3)
->placeholder('bar')
->maxLength(10)
->translatable(),
Color::make()
->name('color'),
Checkbox::make()
->name('active')
->translatable()
->confirmMessageText('Are you sure?'),
Checkboxes::make()
->name('city')
->inline()
->border()
->options(
Options::make([
Option::make('brussels', 'Brussels'),
Option::make('paris', 'Paris'),
Option::make('amsterdam', 'Amsterdam'),
])
),
BlockEditor::make()
->blocks(['text']),
Tags::make(),
Browser::make()
->modules([Category::class])
->wide(),
]);
}
} |
Description
This is not finished, backwards compatibility has not been implemented.
The idea here is to, in addition to @formfield we also have the option to use blade-x components.
So this:
would become this:
Each form field would have its own blade-x component.
By doing this we can also free the partials from additional PHP.
(there is not much abstraction done yet so I think in a final product the component class will have fewer data.)
Todo:
Fixes
fixes #969