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:Jump to solution
The required method accepts a callback and you can inject the current operation into that callback:
...
6 Replies
->required(fn($context) => $context === 'create')
Solution
The required method accepts a callback and you can inject the current operation into that callback:
Pretty sure it's 'operation' and not 'context'?
Could be in V3... not fully on it yet
worked perfectly, thank you. π
$context still works in v3 for legacy. But $operation is correct.