backend.form.extendFieldsBefore
Triggered in Backend\Widgets\Form.
Called before the form fields are defined
Example usage:
Event::listen('backend.form.extendFieldsBefore', function ((\Backend\Widgets\Form) $widget) {
// You should always check to see if you're extending correct model/controller
if (!$widget->model instanceof \Foo\Example\Models\Bar) {
return;
}
// Add a new field named example_field
$widget->addField('example_field', [
'label' => 'Example field',
'comment' => 'Your example field',
'type' => 'text'
]);
});
Or
$formWidget->bindEvent('form.extendFieldsBefore', function () use ((\Backend\Widgets\Form $formWidget)) {
// You should always check to see if you're extending correct model/controller
if (!$widget->model instanceof \Foo\Example\Models\Bar) {
return;
}
// Add a new field named example_field
$widget->addField('example_field', [
'label' => 'Example field',
'comment' => 'Your example field',
'type' => 'text'
]);
});