How to modify existing form fields?
0
\Event::listen('backend.form.extendFieldsBefore', function($widget) {
if ($widget->isNested) {
return;
}
if ($widget->getController() instanceof Products && $widget->model instanceof Product) {
$widget->tabs['fields']['additional_descriptions']['form']['fields'] = [
'new' => [
'type' => 'text',
'label' => 'My New Field',
],
'another' => [
'type' => 'text',
'label' => 'My Other Field',
],
];
}
});
Don't forget to check for $form->isNested in your event handler, otherwise that creates problems with nested form widgets (like repeater and nestedforms)
if ($widget->isNested) {
return;
}
There are no comments yet
Be the first one to comment