F
Filament2mo ago
Satal

Numeric but can be blank

I have a form that includes the following
Forms\Components\TextInput::make('company_number')
->label('Company Number')
->numeric()
->nullable(),
Forms\Components\TextInput::make('company_number')
->label('Company Number')
->numeric()
->nullable(),
However, when I try to submit the form, if this field is left blank, I get the following validation error
The company Number field must be a number.
Is there a way to require the field to be numeric or blank? Also as a slight aside, how do I capitalise the 'c' in the validation error?
No description
2 Replies
awcodes
awcodes2mo ago
Try doing nullable() before numeric() Sometime the order matters. If that doesn’t work you can always do it manually with ->rules([‘nullable’, ‘digits’]) Things like nullable and sometimes have to be first in the validations in laravel since they will bail the validation.
Satal
Satal2mo ago
Thanks @awcodes. Unfortunately, even moving nullable() first I get the same error. Weirdly though, when I tried the second suggestiong using 'digits' it showed some weird characters in the field even though it should be blank.