diff --git a/src/Forms/Components/Form.php b/src/Forms/Components/Form.php index f3c60ab7..1f8cbf14 100644 --- a/src/Forms/Components/Form.php +++ b/src/Forms/Components/Form.php @@ -24,6 +24,8 @@ public function submit(): void $this->callHook('afterValidate'); $this->store(); + + $this->callHook('afterSubmit'); } public function check(): void diff --git a/src/Views/Forms/CreateForm.php b/src/Views/Forms/CreateForm.php index dfe6a114..669fd944 100644 --- a/src/Views/Forms/CreateForm.php +++ b/src/Views/Forms/CreateForm.php @@ -6,6 +6,8 @@ abstract class CreateForm extends Form { public function submit(): void { + $this->canCreate($this->modelClass); + parent::submit(); $this->callHook('beforeHandle'); @@ -15,11 +17,6 @@ public function submit(): void $this->callHook('afterHandle'); } - protected function beforeValidate(): void - { - $this->canCreate($this->modelClass); - } - protected function set(string $class): void { $this->canCreate($class); diff --git a/src/Views/Forms/UpdateForm.php b/src/Views/Forms/UpdateForm.php index ccecb7c5..c55613ff 100644 --- a/src/Views/Forms/UpdateForm.php +++ b/src/Views/Forms/UpdateForm.php @@ -8,6 +8,8 @@ class UpdateForm extends Form { public function submit(): void { + $this->canUpdate($this->model); + parent::submit(); $this->callHook('beforeHandle'); @@ -19,18 +21,11 @@ public function submit(): void public function delete(): void { - throw_if(! $this->model); - $this->canDelete($this->model); $this->model->delete(); } - protected function beforeValidate(): void - { - $this->canUpdate($this->model); - } - protected function set(Model $model): void { $this->canUpdate($model);