Closed m49n closed 4 months ago
Hi,
please write me what you are trying to do, so I can confirm this.
For example, this code will override form css class property and it is rendered correctly without passing argument by reference:
Event::listen('formBuilder.overrideForm', function ($form) {
$form->css_class = 'my_class';
});
Hi,
please write me what you are trying to do, so I can confirm this.
For example, this code will override form css class property and it is rendered correctly without passing argument by reference:
Event::listen('formBuilder.overrideForm', function ($form) { $form->css_class = 'my_class'; });
Hi, for example I want to override the entire form
Event::listen('formBuilder.overrideForm', function (&$form) {
if (request()->form) {
$form = Form::query()
->with([
'fields' => fn($query) => $query->isVisible()->with('field_type'),
])
->where('code', request()->form)
->firstOrFail();
}
});
Describe the bug it is impossible to change an object in an event
Fix was: event('formBuilder.overrideForm', [$this->form]); became event('formBuilder.overrideForm', [&$this->form]);
and Event::listen('formBuilder.overrideForm', function (&$form) with &
same in other events was: event('formBuilder.formSubmitted', [$this->form]); became: event('formBuilder.formSubmitted', [&$this->form]);
Plugin version 4.0.5
Additional context Problem with new events
@mplodowski Hi, What about this? the reference will not affect the functionality of the event in any way, but it will add the ability to completely redefine the object if necessary.
Thanks and sorry for long wait!
Resolved in v4.0.6
Describe the bug it is impossible to change an object in an event
Fix was: event('formBuilder.overrideForm', [$this->form]); became event('formBuilder.overrideForm', [&$this->form]);
and Event::listen('formBuilder.overrideForm', function (&$form) with &
same in other events was: event('formBuilder.formSubmitted', [$this->form]); became: event('formBuilder.formSubmitted', [&$this->form]);
Plugin version 4.0.5
Additional context Problem with new events