Form Data
Form properties related to form data
public Model $model;
public array $form_data;
Access data
The data is always accessible via:
data_get($this->form_data, 'foo')
or the fields
name
property, like$this->foo
, depending on how you setup your formIn Lifecycle Hooks you access custom field data via
data_get($this->form_data, 'foo')
Model
The model you pass in the mount_form($model)
method is accessed as $this->model
Example
protected function onCreateModel($validated_data)
{
data_set($this->form_data, 'password', Hash::make(data_get($this->form_data, 'password')));
//or
$this->form_data['password'] = Hash::make($this->form_data['password']);
//or
$this->model = User::create($validated_data);
}
FileUpload fields
This data is never available in the form_data
property, you access it with $this->foo
because Livewire v2 requires you to define the property on the component.
Last updated
Was this helpful?