@@ 82-109 (lines=28) @@ | ||
79 | * @throws \Ffcms\Core\Exception\SyntaxException |
|
80 | * @throws \Ffcms\Core\Exception\NativeException |
|
81 | */ |
|
82 | public function actionUpdate($id) |
|
83 | { |
|
84 | // get item with trashed objects |
|
85 | $record = ContentEntity::withTrashed()->find($id); |
|
86 | $isNew = $record->id === null; |
|
87 | ||
88 | // create empty object if its new |
|
89 | if ($isNew === true) { |
|
90 | $record = new ContentEntity(); |
|
91 | } |
|
92 | ||
93 | // init model |
|
94 | $model = new FormContentUpdate($record); |
|
95 | ||
96 | // check if model is submit |
|
97 | if ($model->send() && $model->validate()) { |
|
98 | $model->save(); |
|
99 | if ($isNew === true) { |
|
100 | App::$Response->redirect('content/index'); |
|
101 | } |
|
102 | App::$Session->getFlashBag()->add('success', __('Content is successful updated')); |
|
103 | } |
|
104 | ||
105 | // draw response |
|
106 | return App::$View->render('content_update', [ |
|
107 | 'model' => $model |
|
108 | ]); |
|
109 | } |
|
110 | ||
111 | /** |
|
112 | * Delete content by id |
@@ 123-145 (lines=23) @@ | ||
120 | * @param $id |
|
121 | * @return string |
|
122 | */ |
|
123 | public function actionFieldupdate($id) |
|
124 | { |
|
125 | // get current record or new and init form DI |
|
126 | $record = ProfileField::findOrNew($id); |
|
127 | $model = new FormFieldUpdate($record); |
|
128 | ||
129 | $isNew = false; |
|
130 | if ($record->id === null) { |
|
131 | $isNew = true; |
|
132 | } |
|
133 | // check if form is submited |
|
134 | if ($model->send() && $model->validate()) { |
|
135 | $model->save(); |
|
136 | if (true === $isNew) { |
|
137 | App::$Response->redirect('profile/fieldlist'); |
|
138 | } |
|
139 | App::$Session->getFlashBag()->add('success', __('Profile field was successful updated')); |
|
140 | } |
|
141 | ||
142 | return App::$View->render('field_update', [ |
|
143 | 'model' => $model->export() |
|
144 | ]); |
|
145 | } |
|
146 | ||
147 | /** |
|
148 | * Delete custom field action |