1 | <?php |
||
2 | |||
3 | namespace Apps\Controller\Admin\Profile; |
||
4 | |||
5 | use Apps\ActiveRecord\ProfileField; |
||
6 | use Apps\Model\Admin\Profile\FormFieldUpdate; |
||
7 | use Ffcms\Core\App; |
||
8 | use Ffcms\Core\Arch\View; |
||
9 | use Ffcms\Core\Network\Request; |
||
10 | use Ffcms\Core\Network\Response; |
||
11 | |||
12 | /** |
||
13 | * Trait ActionFieldUpdate |
||
14 | * @package Apps\Controller\Admin\Profile |
||
15 | * @property Request $request |
||
16 | * @property Response $response |
||
17 | * @property View $view |
||
18 | */ |
||
19 | trait ActionFieldUpdate |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Add new or edit exist additional fields for user profiles |
||
24 | * @param string|null $id |
||
25 | * @return string |
||
26 | * @throws \Ffcms\Core\Exception\SyntaxException |
||
27 | */ |
||
28 | public function profileFieldUpdate($id = null) |
||
29 | { |
||
30 | // get current record or new and init form DI |
||
31 | $record = ProfileField::findOrNew($id); |
||
32 | $model = new FormFieldUpdate($record); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
33 | |||
34 | // check if form is submitted |
||
35 | if ($model->send() && $model->validate()) { |
||
36 | $model->save(); |
||
37 | if ($record->id) { |
||
38 | $this->response->redirect('profile/fieldlist'); |
||
39 | } |
||
40 | App::$Session->getFlashBag()->add('success', __('Profile field was successful updated')); |
||
41 | } |
||
42 | |||
43 | return $this->view->render('profile/field_update', [ |
||
44 | 'model' => $model |
||
45 | ]); |
||
46 | } |
||
47 | } |
||
48 |