#Custom validation with HTML
19 messages · Page 1 of 1 (latest)
$fail(__('The cumulative percentage is higher than 100% <a href="#">Some link here</a>');
Custom validation with HTML
Not sure but something you can try:
$fail(new HtmlString(__('...')));
I tried this, it will just output the HTML 😦
Ok... this would have been too easy 😄
So I'm not sure how you would go about it correctly, but I think a workaround could be to just output a custom error message in this case, maybe something like this in your Blade template:
@error('my_field')
The cumulative percentage is higher than 100% <a href="#">Some link here</a>
@enderror
I'm using the Filament Admin Panel where i have a custom validation for a Select. @final granite
Ok, makes sense. So maybe one option would be to show a custom error message in a View component... are you familiar with that?
I have done it before in Laravel itself, but not sure how i would do it in Filament Panel 🤔
Example what im currently doing:
Select::make('example')->rules(new CustomRuleExample), // php artisan make:rule CustomRuleExample
Yes, I think your approach is correct but the only issue is the HTML doesn't work in the validation error message...
So you said you would solve it via a view?
It's a workaround. Basically I'm trying to think of a way for you to display your custom HTML.
I mean.. its not a big deal basically sometimes i give a validation error where i indicate what Customer is using something and then that customer name would be a link to the CustomerResource.
I was just wondering if it could be done easily, but seems like its not how its meant to work 🤣
Hehe. I feel like there's a way, just I can't quite remember. I'm sure I did it in the past 😵💫
Hmmm