@@ 88-115 (lines=28) @@ | ||
85 | * @throws \Ffcms\Core\Exception\SyntaxException |
|
86 | * @throws \Ffcms\Core\Exception\NativeException |
|
87 | */ |
|
88 | public function actionUpdate($id = null) |
|
89 | { |
|
90 | // get item with trashed objects |
|
91 | $record = ContentEntity::withTrashed()->findOrNew($id); |
|
92 | $isNew = $record->id === null; |
|
93 | ||
94 | // create empty object if its new |
|
95 | if ($isNew === true) { |
|
96 | $record = new ContentEntity(); |
|
97 | } |
|
98 | ||
99 | // init model |
|
100 | $model = new FormContentUpdate($record); |
|
101 | ||
102 | // check if model is submit |
|
103 | if ($model->send() && $model->validate()) { |
|
104 | $model->save(); |
|
105 | if ($isNew === true) { |
|
106 | $this->response->redirect('content/index'); |
|
107 | } |
|
108 | App::$Session->getFlashBag()->add('success', __('Content is successful updated')); |
|
109 | } |
|
110 | ||
111 | // draw response |
|
112 | return $this->view->render('content_update', [ |
|
113 | 'model' => $model |
|
114 | ]); |
|
115 | } |
|
116 | ||
117 | /** |
|
118 | * Delete content by id |
@@ 133-155 (lines=23) @@ | ||
130 | * @throws \Ffcms\Core\Exception\SyntaxException |
|
131 | * @throws \Ffcms\Core\Exception\NativeException |
|
132 | */ |
|
133 | public function actionFieldupdate($id) |
|
134 | { |
|
135 | // get current record or new and init form DI |
|
136 | $record = ProfileField::findOrNew($id); |
|
137 | $model = new FormFieldUpdate($record); |
|
138 | ||
139 | $isNew = false; |
|
140 | if ($record->id === null) { |
|
141 | $isNew = true; |
|
142 | } |
|
143 | // check if form is submited |
|
144 | if ($model->send() && $model->validate()) { |
|
145 | $model->save(); |
|
146 | if (true === $isNew) { |
|
147 | $this->response->redirect('profile/fieldlist'); |
|
148 | } |
|
149 | App::$Session->getFlashBag()->add('success', __('Profile field was successful updated')); |
|
150 | } |
|
151 | ||
152 | return $this->view->render('field_update', [ |
|
153 | 'model' => $model |
|
154 | ]); |
|
155 | } |
|
156 | ||
157 | /** |
|
158 | * Delete custom field action |