| Conditions | 2 |
| Paths | 2 |
| Total Lines | 18 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | public function html(Request $request, Response $response, Admin $app, $entityName) |
||
| 13 | { |
||
| 14 | $id = $request->getAttribute('id'); |
||
| 15 | $field = $request->getAttribute('field'); |
||
| 16 | $data = $request->getParsedBody(); |
||
| 17 | |||
| 18 | $form = static::createForm($app, $entityName, $id); |
||
| 19 | $form['data']->val($app->getEntity($entityName)->read($id)); |
||
| 20 | $form['data'][$field]->val($data['value']); |
||
| 21 | |||
| 22 | if ($form->validate()) { |
||
| 23 | $app->getEntity($entityName)->update($id, $form['data']->val()); |
||
| 24 | |||
| 25 | return $data['value']; |
||
| 26 | } |
||
| 27 | |||
| 28 | return $response->withStatus(400); |
||
| 29 | } |
||
| 30 | } |
||
| 31 |