Custom Toggle
Is it possible to obtain the current record and the state of the toggle, true or false, in order to perform operations when saving or updating the form, so that based on that record and toggle state, custom operations can be performed, such as creating or editing other different models and the database?
Forms\Components\Toggle::make('custom'),
Solution:Jump to solution
you can work with toggle, but I think you should use some methods to customize data before filling the form and before saving it to the database
Check this section for EditPage: https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-data-before-filling-the-form...
4 Replies
Could you explain what are you trying to do?
Good afternoon. In my db, there's a model that has many options. For an admin, Select->multiple() works well, but there's another user with a different role who should only be able to add or remove a specific option from the model. I thought about using a toggle, but I'm not sure how to implement it
Solution
you can work with toggle, but I think you should use some methods to customize data before filling the form and before saving it to the database
Check this section for EditPage: https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-data-before-filling-the-form
Thanks! I used https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-the-saving-process and it worked perfectly