Setting a form model
Giving the $form access to a model is useful for a few reasons:
- It allows fields within that form to load information from that model. For example, select fields can load their options from the database automatically.
- The form can load and save the model's relationship data automatically. For example, you have an Edit Post form, with a Repeater which manages comments associated with that post. Filament will automatically load the comments for that post when you call $this->form->fill([...]), and save them back to the relationship when you call $this->form->getState().
- Validation rules like exists() and unique() can automatically retrieve the database table name from the model.
It is advised to always pass the model to the form when there is one. As explained, it unlocks many new powers of the Filament Form Builder.
To pass the model to the form, use the $form->model() method:
Course Curriculum
-
-
file_example_MP4_480_1_5MG 00:00:30 -
file_example_MP4_480_1_5MG 00:00:30 -
file_example_MP4_480_1_5MG 00:00:30 -
file_example_MP4_480_1_5MG 00:00:30 -
file_example_MP4_480_1_5MG 00:00:30 -
file_example_MP4_480_1_5MG 00:00:30
-
Announcement

Courses | 4
Students | 0
Rating 0
Reviews (0)
You must login to leave a comment
- 6 chapters
- 03:00
-
Certificate of Completion