Manually saving data
FieldFoo::make('Foo')->custom()
If you want to be in control of how a field is saved add the custom()
method to the field
FieldFoo::make('Foo')->relation()
The relation()
method does the same as custom()
, it is just there for code readability
saveFoo() - save the data
If you used the custom()
or relation()
method on your field, it will be excluded from the default save method, so you must save them yourself via the saveFoo()
hook.
The method is executed AFTER field validation and AFTER the model is created or updated, meaning that you have access to $this->model
even if it is a create
form.
You do NOT have to prefix with FormData
Example method name for an array field
form_data.people.name
will becomesavePeopleName($validated_value)
Example method name for
form_data.some_field_name
will becomesaveSomeFieldName($validated_value)
Example; form_data.price
Last updated
Was this helpful?