F
Filament3mo ago
MZX

Form not taking input when using disabled() on a field

Forms\Components\TextInput::make('amount')
->disabled()
->label('Amount (€)')
->numeric(),
Forms\Components\TextInput::make('amount')
->disabled()
->label('Amount (€)')
->numeric(),
when I remove disabled, the record is being created, if I use disabled, get an error that the field is missing.
Solution:
Disabled() removes the field from the form state. So, if you want to show it as a form input then you’ll need to make it either readonly or use dehydrated() like you have done. Or if the appearance is less vital then you can use a Placeholder field instead.
Jump to solution
3 Replies
MZX
MZX3mo ago
I don't know why, but using dehydrated() fixed it. Would really appreciate it if someone could.
Solution
awcodes
awcodes3mo ago
Disabled() removes the field from the form state. So, if you want to show it as a form input then you’ll need to make it either readonly or use dehydrated() like you have done. Or if the appearance is less vital then you can use a Placeholder field instead.
MZX
MZX3mo ago
Alright got it! Thanks a lot buddy.
Want results from more Discord servers?
Add your server