F
Filament2mo ago
aldec

Validation Rules only on create

Is it possible to have validation rules only apply in the create step but not on later editing?
Solution:
use operation ```php TextInput::make('title') ->required(fn (string $operation) => $operation === 'create')...
Jump to solution
2 Replies
Solution
LeandroFerreira
LeandroFerreira2mo ago
use operation
TextInput::make('title')
->required(fn (string $operation) => $operation === 'create')
->rules(fn (string $operation): array => $operation === 'create' ? ['your-rules'] : [])
TextInput::make('title')
->required(fn (string $operation) => $operation === 'create')
->rules(fn (string $operation): array => $operation === 'create' ? ['your-rules'] : [])
aldec
aldecOP2mo ago
Perfect, thanks!

Did you find this page helpful?