Conditionally create non-editable fields
There are a function that create a "TextInput" no editable for the user? I would like to send "generated" data based on others fields, then, put it at non editable field like *username * based on real user name.
Disabled fields cannot be sent due to their own disabled status.
How can I achieve this function?
Solution:Jump to solution
See use of dehydrated() in the docs on disabling. A field which is ->disabled()->dehdrated() will be submitted with the form.
If you are worried about people spoofing it, you can always re-create the value from your other fields on save with a dehydrateStateUsing() method.
https://filamentphp.com/docs/3.x/forms/fields/getting-started#disabling-a-field...
2 Replies
Solution
See use of dehydrated() in the docs on disabling. A field which is ->disabled()->dehdrated() will be submitted with the form.
If you are worried about people spoofing it, you can always re-create the value from your other fields on save with a dehydrateStateUsing() method.
https://filamentphp.com/docs/3.x/forms/fields/getting-started#disabling-a-field
Thank you! you're right! I take a look at it