Validation messages
Hello everyone, why am I not getting validation messages anymore, but instead, I see this?
Solution:Jump to solution
If you don’t want browser validation don’t use ->required() instead use ->rules([‘required’])
22 Replies
Because
->required()
put both backend and html validation in input. I don't understand the text but it showing like "Please fill out this form"if you put
->native(false)
It should show validation message
@Vp , Okay, but until yesterday, the validation message appeared to me.
I think
->native()
only exists for DatePicker (and maybe Select). The behaviour is expected
You will still get validation messages for stuff that the browser can't handleSo, the browser validation can't be disabled? Yesterday it wasn't showing for me...
I don't think so. Did you update Filament?
No, I have only installed this plugin [link] https://filamentphp.com/plugins/eightynine-excel-import.
I doubt that it magically appeared. So either there was an update or you changed some code.
I installed the plugin... I wouldn't even know how to hide the validation messages...
another thing... I'm using git and even if I go back to a previous commit (even the first one) the problem remains
I just checked: This wasn't changed from v3-alpha.
ok, but then I don't understand
This is the only change to the composer.json file
Can anyone tell me how I can try to solve the problem?
Solution
If you don’t want browser validation don’t use ->required() instead use ->rules([‘required’])
thank you so much
Hi @awcodes, rules(['required']) works fine, but however * no longer appears next to the field name
->markAsRequired()
Something like that
mmmm
it doesn't seem to work
I would expect it to. Not sure then.
Personally I would default to the browser validation since it saves on a trip to the server.
This is true, although graphically I prefer Laravel's validation messages
@awcodes Why doesn't this validation rule work? Where am I going wrong?
Forms\Components\Toggle::make('is_private')
->default(false)
->label(__('students.is_private')),
Select::make('customer_id')
->rules(['required_if:is_private,false'])
->label('Cliente*')
->options(Customer::all()->pluck('name', 'id'))
->searchable()
->autofocus(),
The data is stored in
data
so the rule should be required_if:data.is_private,false
. That's why we have custom methods for thesedid get the answer? i am also stuck on this.
Thank God. This should be mentioned on the Doc. ✅
It’s a bit special use case. Not everything can be in the docs.