-
-
Notifications
You must be signed in to change notification settings - Fork 86
Custom Data
tanthammar edited this page Nov 13, 2020
·
3 revisions
If you want to be in control of how a field is saved add the custom()
method to the field
Input::make('My custom field', 'foo')
->custom()
->rule('required'),
You must save the data your self, the custom fields are excluded from the default save method.
You can omit FormData
in the method name, if it is an array like form_data.name.sv
the method name becomes saveNameSv()
The data is accessed via data_get($form_data, 'customname')
or the fields name
property, like $this->fieldname
, depending on how you setup your form
Meaning that you have access to $this->model
.
public function saveFoo($validated_value)
{
// get the field value via the fields name property
$field_value = $validated_value;
//or
$field_value = $this->foo;
//save the data
$this->model->foo = $field_value;
}
A nice combination is to use the custom property together with a custom view. This way you can make any field you want.
Input::make('My custom field', 'customname')
->custom()
->view('path.mybladeview')
->rule('required'),
- Installation
- Requirements
- v5 Upgrade Guide
- v6 Upgrade Guide
- v7 Upgrade Guide
- Support
- Quickstart
- Manual installation
- Optional
- Form component
- Field
- Field types
- Example Form
- Blade Components
- Notifications