Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function update(?string $id = null): ?string |
||
29 | { |
||
30 | $user = UserRecord::findOrNew($id); |
||
31 | // generate model data based on user object |
||
32 | $model = new FormUserUpdate($user); |
||
|
|||
33 | |||
34 | // check is form is sended |
||
35 | if ($model->send()) { |
||
36 | if ($model->validate()) { // check validation |
||
37 | $model->save(); |
||
38 | App::$Session->getFlashBag()->add('success', __('Data was successful updated')); |
||
39 | } else { |
||
40 | App::$Session->getFlashBag()->add('error', __('Form validation is failed')); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | // render viewer |
||
45 | return $this->view->render('user/user_update', [ |
||
46 | 'model' => $model |
||
47 | ]); |
||
50 |