@@ 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 |
@@ 86-113 (lines=28) @@ | ||
83 | * @throws \Ffcms\Core\Exception\SyntaxException |
|
84 | * @throws \Ffcms\Core\Exception\NativeException |
|
85 | */ |
|
86 | public function actionUpdate($id = null) |
|
87 | { |
|
88 | // get item with trashed objects |
|
89 | $record = ContentEntity::withTrashed()->findOrNew($id); |
|
90 | $isNew = $record->id === null; |
|
91 | ||
92 | // create empty object if its new |
|
93 | if ($isNew === true) { |
|
94 | $record = new ContentEntity(); |
|
95 | } |
|
96 | ||
97 | // init model |
|
98 | $model = new FormContentUpdate($record); |
|
99 | ||
100 | // check if model is submit |
|
101 | if ($model->send() && $model->validate()) { |
|
102 | $model->save(); |
|
103 | if ($isNew === true) { |
|
104 | App::$Response->redirect('content/index'); |
|
105 | } |
|
106 | App::$Session->getFlashBag()->add('success', __('Content is successful updated')); |
|
107 | } |
|
108 | ||
109 | // draw response |
|
110 | return App::$View->render('content_update', [ |
|
111 | 'model' => $model |
|
112 | ]); |
|
113 | } |
|
114 | ||
115 | /** |
|
116 | * Delete content by id |