© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
8 replies
daar

Conditional rules not working

Hi, I want to enable custom rules conditionally, but this is not being called. What am I missing here? I have attached the code used below.

                                Forms\Components\Select::make('identification_type')
  ->label(__('Identification type'))
  ->options(IdentificationType::class)
  ->live()
  ->required(),                              Forms\Components\TextInput::make('citizen_service_number')
  ->label(__('Identification number'))
  ->rules([
    static fn (Get $get): Closure => static function (string $attribute, $value, Closure $fail) use ($get): void {
      if ($get('identification_type') === IdentificationType::CEDULA->value) {
        $cedula = new Cedula($value);
          if ( ! $cedula->isValid()) {
            $fail(__('The citizen service number is invalid'));
          }
        }
      },
    ])
    ->maxLength(255),
                                Forms\Components\Select::make('identification_type')
  ->label(__('Identification type'))
  ->options(IdentificationType::class)
  ->live()
  ->required(),                              Forms\Components\TextInput::make('citizen_service_number')
  ->label(__('Identification number'))
  ->rules([
    static fn (Get $get): Closure => static function (string $attribute, $value, Closure $fail) use ($get): void {
      if ($get('identification_type') === IdentificationType::CEDULA->value) {
        $cedula = new Cedula($value);
          if ( ! $cedula->isValid()) {
            $fail(__('The citizen service number is invalid'));
          }
        }
      },
    ])
    ->maxLength(255),
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

Conditional ImportColumn rules
FilamentFFilament / ❓┊help
3y ago
validation message in rules not working
FilamentFFilament / ❓┊help
2y ago
Conditional Fields
FilamentFFilament / ❓┊help
2y ago
Conditional plugin
FilamentFFilament / ❓┊help
2y ago