backend.form.extendFields
Called after the form fields are defined
Example usage:
Event::listen('backend.form.extendFields', function ((\Backend\Widgets\Form) $formWidget) {
// Check that we're extending the correct Form widget instance
if (
!($formWidget->getController() instanceof \Winter\User\Controllers\Users)
|| !($formWidget->model instanceof \Winter\User\Models\User)
|| $formWidget->isNested
) {
return;
}
// Add an extra birthday field
$formWidget->addFields([
'birthday' => [
'label' => 'Birthday',
'comment' => 'Select the users birthday',
'type' => 'datepicker'
]
]);
// Remove a Surname field
$formWidget->removeField('surname');
});
Or
$formWidget->bindEvent('form.extendFields', function () use ((\Backend\Widgets\Form $formWidget)) {
// Check that we're extending the correct Form widget instance
if (
!($formWidget->getController() instanceof \Winter\User\Controllers\Users)
|| !($formWidget->model instanceof \Winter\User\Models\User)
|| $formWidget->isNested
) {
return;
}
// Add an extra birthday field
$formWidget->addFields([
'birthday' => [
'label' => 'Birthday',
'comment' => 'Select the users birthday',
'type' => 'datepicker'
]
]);
// Remove a Surname field
$formWidget->removeField('surname');
});
Usage
Triggers
Class or file | Line |
---|---|
Backend\Widgets\Form
|
631 |
Copyright © 2024 Winter CMS