| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 21 | 
| Code Lines | 13 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 12 | public function json(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 json_encode([  | 
            ||
| 26 | 'value' => $form['data'][$field]->val(),  | 
            ||
| 27 | 'htmlValue' => $form['data'][$field]->valToHtml(),  | 
            ||
| 28 | ]);  | 
            ||
| 29 | }  | 
            ||
| 30 | |||
| 31 | return $response->withStatus(400);  | 
            ||
| 32 | }  | 
            ||
| 33 | }  | 
            ||
| 34 |