Saving hidden fields in a wizard component
Hello All,
Any workaround on how to save hidden form field upon form submit. The field is "unit_cost_price" as shown in the attach image.
note: without the hidden attribute, it works fine as expected, the issue arises when I chained the hidden method
4 Replies
Mutate it before creating/ editing?
https://filamentphp.com/docs/3.x/panels/resources/creating-records/#customizing-data-before-saving
->hidden() removes the field completely from the form. Whereas a Hidden::make() will create a hidden input. But seeing as this has to do with cost it is best to handle this as Leandro suggested on the backend. Hidden inputs can be manipulated on the front end.
Hey, Leandro's recommendation was initially considered, however, the "unit_cost_price" field is part of a relationship called on a Repeater component and can't access the relationship data on the backend. Basically the relationship is not part of the submitted form data.
I think if you want to save it manually, you could do
->dehydrated(true)
in the repeater and get the data using hooks