Validation messages

Hello everyone, why am I not getting validation messages anymore, but instead, I see this?
Solution:
If you don’t want browser validation don’t use ->required() instead use ->rules([‘required’])
Jump to solution
22 Replies
NeerGreeN
NeerGreeNOP11mo ago
Vp
Vp11mo ago
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"
jaocero
jaocero11mo ago
if you put ->native(false) It should show validation message
NeerGreeN
NeerGreeNOP11mo ago
@Vp , Okay, but until yesterday, the validation message appeared to me.
Dennis Koch
Dennis Koch11mo ago
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 handle
NeerGreeN
NeerGreeNOP11mo ago
So, the browser validation can't be disabled? Yesterday it wasn't showing for me...
Dennis Koch
Dennis Koch11mo ago
I don't think so. Did you update Filament?
NeerGreeN
NeerGreeNOP11mo ago
No, I have only installed this plugin [link] https://filamentphp.com/plugins/eightynine-excel-import.
Dennis Koch
Dennis Koch11mo ago
I doubt that it magically appeared. So either there was an update or you changed some code.
NeerGreeN
NeerGreeNOP11mo ago
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
Dennis Koch
Dennis Koch11mo ago
I just checked: This wasn't changed from v3-alpha.
NeerGreeN
NeerGreeNOP11mo ago
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
awcodes
awcodes11mo ago
If you don’t want browser validation don’t use ->required() instead use ->rules([‘required’])
NeerGreeN
NeerGreeNOP11mo ago
thank you so much Hi @awcodes, rules(['required']) works fine, but however * no longer appears next to the field name
awcodes
awcodes11mo ago
->markAsRequired() Something like that
NeerGreeN
NeerGreeNOP11mo ago
mmmm it doesn't seem to work
awcodes
awcodes11mo ago
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.
NeerGreeN
NeerGreeNOP11mo ago
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(),
Dennis Koch
Dennis Koch11mo ago
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 these
prapok01
prapok0111mo ago
did get the answer? i am also stuck on this.
Hasith
Hasith7mo ago
Thank God. This should be mentioned on the Doc. ✅
Dennis Koch
Dennis Koch7mo ago
It’s a bit special use case. Not everything can be in the docs.
Want results from more Discord servers?
Add your server