© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
Hemith

Accessing the current model inside custom validation rule

Hi. Is there a way to access the current model value inside the custom validation function?
   Forms\Components\Radio::make('status')
                    ->options([
                        'draft' => 'Draft',
                        'public' => 'Public'
                    ])
                    ->descriptions([
                        'draft' => 'Will not be visible to students',
                        'public' => 'Will be visible to students'
                    ])
                    ->hiddenOn('create')
                    ->default('draft')
                    ->rules([
                        function () {
                            return function (string $attribute, $value, Closure $fail) {
                                  // Here
                            };
                        }
                    ])
                    ->required(),
   Forms\Components\Radio::make('status')
                    ->options([
                        'draft' => 'Draft',
                        'public' => 'Public'
                    ])
                    ->descriptions([
                        'draft' => 'Will not be visible to students',
                        'public' => 'Will be visible to students'
                    ])
                    ->hiddenOn('create')
                    ->default('draft')
                    ->rules([
                        function () {
                            return function (string $attribute, $value, Closure $fail) {
                                  // Here
                            };
                        }
                    ])
                    ->required(),

I want to check if the model has children or not.
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

Custom Rule - Current record?
FilamentFFilament / ❓┊help
16mo ago
Get current model inside relationManager
FilamentFFilament / ❓┊help
2y ago
Accessing the resource/model inside Stats Overview widget
FilamentFFilament / ❓┊help
2y ago