Issue with modal form

Hi, am working on creating a modal popup form for change password in edit mode in user resource. I have tried to workout a form as given in example but when i tried - the form dose not popup .. instead it makes a call to the given action which is expecting data on submission of the form. Can someone please help in the same?
3 Replies
blakdronzer
blakdronzerOP15mo ago
Following is the code in action : protected function getActions(): array { return [ Action::make('change_password') ->form([ TextInput::make('password') ->label('New password') ->password() ->confirmed(), TextInput::make('password_confirmation') ->label('Confirm new password') ->password() ]) ->action('updatePassword'), ]; } public function updatePassword(array $data): void { if ($this->record->id != 1) { $this->record->password = Hash::make($data['password']); $this->record->save(); } $this->notify('success', 'Password updated successfully'); }
toeknee
toeknee15mo ago
action needs to be a closure: ->action(fn($data) => // password change code here)
blakdronzer
blakdronzerOP15mo ago
aah i got that - thank you .. it worked!!
Want results from more Discord servers?
Add your server