This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
dev123552
I need to add an attribute to a form field and update it's value when an event is fired. So far I have this:
$widget->bindEvent('form.extendFields', function() use ($widget, $object) {
$this->aMethod($widget, $object);
});
...
protected function aMethod($formWidget, $page)
{
...
//$field = instance of Backend\Classes\FormField
$field = $formWidget->getField($fieldName);
$field->attributes = ['my-attribute' => $myValue];
}
which seems to change $formWidget->allFields
but not the individual field in it's place (it's in a tab) so when the form is loaded the formfield doesn't have that attribute.
Is there a recommended way to update fields?
dev123552
I solved this by binding to the event form.extendFieldsBefore
, so the changes are made before the fields are initialized.
1-2 of 2