Can someone explain to my why ->dehydrated() works for storing data on disabled fields?
I have been using the
->saveRelationshipsWhenDisabled()
method in my Select
relationship fields, and it has been a life saver!
Now I wanted to mimic this behaviour on a standard TextInput
form field, where I found out that adding ->dehydrated()
after ->disabled()
does exactly that. But after reading the documentation on Field dehydration (https://filamentphp.com/docs/3.x/forms/advanced#field-dehydration) a dozen times, my brain still can't comprehend this concept.
Any help understanding this is highly appreciated!Solution:Jump to solution
->dehydrated() is simply a shorthand for ->dehydrated(true)
if you want the field to not be dehydrated you can add ->dehydrated(false) to it.
dehydrated(false) in plain English means: "Don't send the data in this form field to the backend php"...
4 Replies
Solution
->dehydrated() is simply a shorthand for ->dehydrated(true)
if you want the field to not be dehydrated you can add ->dehydrated(false) to it.
dehydrated(false) in plain English means: "Don't send the data in this form field to the backend php"
From my understanding when a form is "disabled" it is automatically set to ->dehydrated(false).
To more direcly answer your question if you want the textfield to send the data to the backend even when it's disabled you can simply do
Thank you for explaining @miomech!
No problem my friend