1 <?php
2 /**
3 * FormFieldset.php
4 *
5 * @author Elvyrra SAS
6 * @license http://rem.mit-license.org/ MIT
7 */
8
9 namespace Hawk;
10
11 /**
12 * This class describes the behavior of a form fieldset
13 *
14 * @package Form
15 */
16 class FormFieldset{
17 use Utils;
18
19 /**
20 * The fieldset name
21 */
22 public $name,
23
24 /**
25 * The legend of the fieldset
26 */
27 $legend,
28
29 /**
30 * The inputs in this fieldset
31 */
32 $inputs,
33
34 /**
35 * The form this fieldset is associated to
36 */
37 $form,
38
39 /**
40 * The id of the legend tag
41 */
42 $legendId = '';
43
44 /**
45 * Constructor
46 *
47 * @param Form $form The form this fieldset is asssociated to
48 * @param string $name The fieldset name
49 * @param array $inputs The inputs in this fieldset
50 * @param array $params The parameters to apply to this fieldset
51 */
52 public function __construct($form, $name, $inputs= array(), $params = array()){
53 $this->name = $name;
54 $this->form = $form;
55 $this->id = $form->id . '-' . $this->name . '-fieldset';
56 $this->inputs = $inputs;
57 $this->map($params);
58
59 if($this->legend) {
60 $this->legendId = $form->id . '-' . $this->name . '-legend';
61 }
62 }
63
64
65 /**
66 * Set a parameter of the fieldset
67 *
68 * @param string $param the name of the parameter
69 * @param mixed $value The value to apply
70 */
71 public function setParam($param, $value){
72 $this->$param = $value;
73 }
74
75 /**
76 * Display the parameter
77 *
78 * @return string The HTML result to display
79 */
80 public function __toString(){
81 return View::make(
82 Theme::getSelected()->getView(Form::VIEWS_DIR . 'form-fieldset.tpl'), array(
83 'fieldset' => $this,
84 )
85 );
86 }
87 }
88