© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
18 replies
Jon Mason

any way to customize validationMessages for a checkbox?

                Checkbox::make('has_agreed_to_tos')
                    ->accepted()
                    ->required()
                    ->label(fn () => new HtmlString('I agree to the <a href="#"  target="_blank" class="fi-link group/link relative inline-flex items-center justify-center outline-none fi-size-md fi-link-size-md text-sky-500 text-underline">Terms & Conditions</a> and <a href="#" target="_blank" class="fi-link group/link relative inline-flex items-center justify-center outline-none fi-size-md fi-link-size-md text-sky-500 text-underline">Privacy Policy</a>'))
                    ->validationMessages([
                        'accepted' => 'You must agree to the terms and conditions to continue.',
                        'required' => 'test'
                    ])
            ])
                Checkbox::make('has_agreed_to_tos')
                    ->accepted()
                    ->required()
                    ->label(fn () => new HtmlString('I agree to the <a href="#"  target="_blank" class="fi-link group/link relative inline-flex items-center justify-center outline-none fi-size-md fi-link-size-md text-sky-500 text-underline">Terms & Conditions</a> and <a href="#" target="_blank" class="fi-link group/link relative inline-flex items-center justify-center outline-none fi-size-md fi-link-size-md text-sky-500 text-underline">Privacy Policy</a>'))
                    ->validationMessages([
                        'accepted' => 'You must agree to the terms and conditions to continue.',
                        'required' => 'test'
                    ])
            ])

tried both required and accepted separately and together and it always posts the entire content of the label attribute as the error message on the UI, which is obviously not great.

Maybe using label isn't the right approach?
Solution
remove
$this->validate();
$this->validate();
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Any way to make checkbox readonly but not disabled ?
FilamentFFilament / ❓┊help
15mo ago
Custom ValidationMessages for minDate/maxDate
FilamentFFilament / ❓┊help
2y ago
validationMessages not working for regex
FilamentFFilament / ❓┊help
2y ago
validationMessages not work
FilamentFFilament / ❓┊help
2y ago