1 <?php
2 /**
3 * ObjectInput.php
4 *
5 * @author Elvyrra SAS
6 * @license http://rem.mit-license.org/ MIT
7 */
8
9 namespace Hawk;
10
11 /**
12 * This class describe the behavior of an input representing an object.
13 * To be treated, an object must be an array.
14 * To be displayed, an object must be a json string
15 *
16 * @package Form\Input
17 */
18 class ObjectInput extends FormInput{
19 const TYPE="text";
20
21 /**
22 * Display the input
23 *
24 * @return string The HTML result to display
25 */
26 public function display(){
27 if(empty($this->value)) {
28 $this->value = "{}";
29 }
30 elseif(is_array($this->value)) {
31 $this->value = json_encode($this->value, JSON_NUMERIC_CHECK | JSON_HEX_APOS | JSON_HEX_QUOT);
32 }
33
34 return parent::display();
35 }
36
37 }
38