How to customize $fail message (with html too) to an existing rule ?
For example, you are using
->unique(User::class, 'email')
. The default error message will be: "The email has already been taken" since this is coming from the en/validation.php
.
How about if you need html for that like "This email already exists. <a href="url('forgot-password;)">Forgot Password?</a>" ?10 Replies
In which page you are using this rule?
custom form
try to override validate function like this
Up!
@vahnmarty Is this a custom form?
An idea would be to add the link conditionally, in a custom View below your form field:
I want it below in the email textbox.
One thing that worked for me is by using
Placeholder
But this one is using manual validation ->visible(fn(Closure $get) => User::where('email', $get('email'))->exists())
and not the ->unique()
.
----
Ok I'll try this View
Ah nvm, the i think you are referring to the layout
View
https://filamentphp.com/docs/2.x/forms/layout#viewThere is some awkward space in between.
Ah yes, that's because the
View
creates an empty row in the layout... You could try a negative margin-top.
Maybe your Placeholder was a better idea after all ☝️