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
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');
}
action needs to be a closure:
->action(fn($data) => // password change code here)
aah i got that - thank you .. it worked!!