FilamentF
Filament3y ago
Finn

Required but only on create?

Is there a way to set a field to only be required on a create action? For example when editing a user - on create they require a password to be entered but on update they do not always need to update their password.
Solution
The required method accepts a callback and you can inject the current operation into that callback:
->required(fn (string $operation): bool => $operation === 'create')
Was this page helpful?