This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hello,
is there a way to dynamically change the modelClass property on the RecordFinder widget?
Thanks.
You can also use this event:
https://octobercms.com/docs/api/backend/form/extendfieldsbefore
Event::listen('backend.form.extendFieldsBefore', function ($widget) {
// make sure you have the right model & controller here...
if ($widget->getController() instanceof yourController && $widget->model instanceof yourModel) {
$widget->fields['recordFinder_fieldName']['modelClass'] = 'otherClass';
}
});
Thank you. It works in the 'backend.form.extendFieldsBefore' event. When I try the same in the 'backend.form.refreshFields' event, the new modelClass is not used.
I use the 'backend.form.refreshFields' event because RecordFinder dependsOn some other field.
But if you set it using backend.form.extendFieldsBefore
it should still have the same value when you do your things using backend.form.refreshFields
?!
I verified the code flow in the source code and backend.form.extendFieldsBefore
is definitely going to be fired within onRefresh()
BEFORE the backend.form.refreshFields
event is fired.
1-8 of 8