@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class HtmlForm extends HtmlSemCollection { |
22 | 22 | |
23 | - use FieldsTrait,FormTrait; |
|
23 | + use FieldsTrait, FormTrait; |
|
24 | 24 | /** |
25 | 25 | * @var array |
26 | 26 | */ |
@@ -33,14 +33,14 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct($identifier, $elements=array()) { |
35 | 35 | parent::__construct($identifier, "form", "ui form"); |
36 | - $this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ]; |
|
36 | + $this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED]; |
|
37 | 37 | $this->setProperty("name", $this->identifier); |
38 | - $this->_fields=array (); |
|
38 | + $this->_fields=array(); |
|
39 | 39 | $this->_validationParams=[]; |
40 | 40 | $this->addItems($elements); |
41 | 41 | } |
42 | 42 | |
43 | - protected function getForm(){ |
|
43 | + protected function getForm() { |
|
44 | 44 | return $this; |
45 | 45 | } |
46 | 46 | |
@@ -61,14 +61,14 @@ discard block |
||
61 | 61 | * @param string $caption |
62 | 62 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
63 | 63 | */ |
64 | - public function addDivider($caption=NULL){ |
|
65 | - return $this->addContent(new HtmlDivider("",$caption)); |
|
64 | + public function addDivider($caption=NULL) { |
|
65 | + return $this->addContent(new HtmlDivider("", $caption)); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | public function addFields($fields=NULL, $label=NULL) { |
69 | 69 | if (isset($fields)) { |
70 | 70 | if (!$fields instanceof HtmlFormFields) { |
71 | - if (\is_array($fields) === false) { |
|
71 | + if (\is_array($fields)===false) { |
|
72 | 72 | $fields=\func_get_args(); |
73 | 73 | $end=\end($fields); |
74 | 74 | if (\is_string($end)) { |
@@ -78,12 +78,12 @@ discard block |
||
78 | 78 | $label=NULL; |
79 | 79 | } |
80 | 80 | $this->_fields=\array_merge($this->_fields, $fields); |
81 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
|
81 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
82 | 82 | } |
83 | 83 | if (isset($label)) |
84 | 84 | $fields=new HtmlFormField("", $fields, $label); |
85 | 85 | } else { |
86 | - $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
|
86 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count()); |
|
87 | 87 | } |
88 | 88 | $this->addItem($fields); |
89 | 89 | return $fields; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | public function addItem($item) { |
93 | 93 | $item=parent::addItem($item); |
94 | - if (\is_subclass_of($item, HtmlFormField::class) === true) { |
|
94 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
95 | 95 | $this->_fields[]=$item; |
96 | 96 | } |
97 | 97 | return $item; |
@@ -143,10 +143,10 @@ discard block |
||
143 | 143 | return $this->addItem($message); |
144 | 144 | } |
145 | 145 | |
146 | - private function addCompoValidation($js,$compo,$field){ |
|
146 | + private function addCompoValidation($js, $compo, $field) { |
|
147 | 147 | $validation=$field->getValidation(); |
148 | - if(isset($validation)){ |
|
149 | - if(isset($compo)===false){ |
|
148 | + if (isset($validation)) { |
|
149 | + if (isset($compo)===false) { |
|
150 | 150 | $compo=$js->semantic()->form("#".$this->identifier); |
151 | 151 | } |
152 | 152 | $validation->setIdentifier($field->getDataField()->getIdentifier()); |
@@ -155,34 +155,34 @@ discard block |
||
155 | 155 | return $compo; |
156 | 156 | } |
157 | 157 | |
158 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
159 | - if(\sizeof($this->_validationParams)>0) |
|
158 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
159 | + if (\sizeof($this->_validationParams)>0) |
|
160 | 160 | $this->setProperty("novalidate", ""); |
161 | - return parent::compile($js,$view); |
|
161 | + return parent::compile($js, $view); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | public function run(JsUtils $js) { |
165 | 165 | $compo=NULL; |
166 | - foreach ($this->_fields as $field){ |
|
167 | - if($field instanceof HtmlFormField) |
|
166 | + foreach ($this->_fields as $field) { |
|
167 | + if ($field instanceof HtmlFormField) |
|
168 | 168 | $compo=$this->addCompoValidation($js, $compo, $field); |
169 | 169 | } |
170 | - foreach ($this->content as $field){ |
|
171 | - if($field instanceof HtmlFormFields){ |
|
170 | + foreach ($this->content as $field) { |
|
171 | + if ($field instanceof HtmlFormFields) { |
|
172 | 172 | $items=$field->getItems(); |
173 | - foreach ($items as $_field){ |
|
174 | - if($_field instanceof HtmlFormField) |
|
173 | + foreach ($items as $_field) { |
|
174 | + if ($_field instanceof HtmlFormField) |
|
175 | 175 | $compo=$this->addCompoValidation($js, $compo, $_field); |
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
179 | - if(isset($compo)===false){ |
|
179 | + if (isset($compo)===false) { |
|
180 | 180 | return parent::run($js); |
181 | 181 | } |
182 | - if(isset($this->_validationParams["_ajaxSubmit"])){ |
|
183 | - if($this->_validationParams["_ajaxSubmit"] instanceof AjaxCall){ |
|
182 | + if (isset($this->_validationParams["_ajaxSubmit"])) { |
|
183 | + if ($this->_validationParams["_ajaxSubmit"] instanceof AjaxCall) { |
|
184 | 184 | $compilation=$this->_validationParams["_ajaxSubmit"]->compile($js); |
185 | - $compilation=str_ireplace("\"","%quote%", $compilation); |
|
185 | + $compilation=str_ireplace("\"", "%quote%", $compilation); |
|
186 | 186 | $this->onSuccess($compilation); |
187 | 187 | unset($this->_validationParams["_ajaxSubmit"]); |
188 | 188 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | return $this->_bsComponent; |
194 | 194 | } |
195 | 195 | |
196 | - public function addValidationParam($paramName,$paramValue){ |
|
196 | + public function addValidationParam($paramName, $paramValue) { |
|
197 | 197 | $this->_validationParams[$paramName]=$paramValue; |
198 | 198 | return $this; |
199 | 199 | } |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function addHeader($title, $niveau=1, $dividing=true) { |
54 | 54 | $header=new HtmlHeader("", $niveau, $title); |
55 | - if ($dividing) |
|
56 | - $header->setDividing(); |
|
55 | + if ($dividing) { |
|
56 | + $header->setDividing(); |
|
57 | + } |
|
57 | 58 | return $this->addItem($header); |
58 | 59 | } |
59 | 60 | |
@@ -74,14 +75,16 @@ discard block |
||
74 | 75 | if (\is_string($end)) { |
75 | 76 | $label=$end; |
76 | 77 | \array_pop($fields); |
77 | - } else |
|
78 | - $label=NULL; |
|
78 | + } else { |
|
79 | + $label=NULL; |
|
80 | + } |
|
79 | 81 | } |
80 | 82 | $this->_fields=\array_merge($this->_fields, $fields); |
81 | 83 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields); |
82 | 84 | } |
83 | - if (isset($label)) |
|
84 | - $fields=new HtmlFormField("", $fields, $label); |
|
85 | + if (isset($label)) { |
|
86 | + $fields=new HtmlFormField("", $fields, $label); |
|
87 | + } |
|
85 | 88 | } else { |
86 | 89 | $fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count()); |
87 | 90 | } |
@@ -134,12 +137,15 @@ discard block |
||
134 | 137 | */ |
135 | 138 | public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) { |
136 | 139 | $message=new HtmlMessage($identifier, $content); |
137 | - if (isset($header)) |
|
138 | - $message->addHeader($header); |
|
139 | - if (isset($icon)) |
|
140 | - $message->setIcon($icon); |
|
141 | - if (isset($type)) |
|
142 | - $message->setStyle($type); |
|
140 | + if (isset($header)) { |
|
141 | + $message->addHeader($header); |
|
142 | + } |
|
143 | + if (isset($icon)) { |
|
144 | + $message->setIcon($icon); |
|
145 | + } |
|
146 | + if (isset($type)) { |
|
147 | + $message->setStyle($type); |
|
148 | + } |
|
143 | 149 | return $this->addItem($message); |
144 | 150 | } |
145 | 151 | |
@@ -156,23 +162,26 @@ discard block |
||
156 | 162 | } |
157 | 163 | |
158 | 164 | public function compile(JsUtils $js=NULL,&$view=NULL){ |
159 | - if(\sizeof($this->_validationParams)>0) |
|
160 | - $this->setProperty("novalidate", ""); |
|
165 | + if(\sizeof($this->_validationParams)>0) { |
|
166 | + $this->setProperty("novalidate", ""); |
|
167 | + } |
|
161 | 168 | return parent::compile($js,$view); |
162 | 169 | } |
163 | 170 | |
164 | 171 | public function run(JsUtils $js) { |
165 | 172 | $compo=NULL; |
166 | 173 | foreach ($this->_fields as $field){ |
167 | - if($field instanceof HtmlFormField) |
|
168 | - $compo=$this->addCompoValidation($js, $compo, $field); |
|
174 | + if($field instanceof HtmlFormField) { |
|
175 | + $compo=$this->addCompoValidation($js, $compo, $field); |
|
176 | + } |
|
169 | 177 | } |
170 | 178 | foreach ($this->content as $field){ |
171 | 179 | if($field instanceof HtmlFormFields){ |
172 | 180 | $items=$field->getItems(); |
173 | 181 | foreach ($items as $_field){ |
174 | - if($_field instanceof HtmlFormField) |
|
175 | - $compo=$this->addCompoValidation($js, $compo, $_field); |
|
182 | + if($_field instanceof HtmlFormField) { |
|
183 | + $compo=$this->addCompoValidation($js, $compo, $_field); |
|
184 | + } |
|
176 | 185 | } |
177 | 186 | } |
178 | 187 | } |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @property object $_modelInstance; |
17 | 17 | */ |
18 | 18 | |
19 | -trait FormFieldAsTrait{ |
|
19 | +trait FormFieldAsTrait { |
|
20 | 20 | |
21 | 21 | abstract protected function _getFieldIdentifier($prefix); |
22 | - abstract public function setValueFunction($index,$callback); |
|
22 | + abstract public function setValueFunction($index, $callback); |
|
23 | 23 | |
24 | - private function _getLabelField($caption,$icon=NULL){ |
|
25 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
24 | + private function _getLabelField($caption, $icon=NULL) { |
|
25 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
26 | 26 | return $label; |
27 | 27 | } |
28 | 28 | |
@@ -30,22 +30,22 @@ discard block |
||
30 | 30 | * @param HtmlFormField $element |
31 | 31 | * @param array $attributes |
32 | 32 | */ |
33 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
33 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
34 | 34 | $this->_addRules($element, $attributes); |
35 | - if(isset($attributes["callback"])){ |
|
35 | + if (isset($attributes["callback"])) { |
|
36 | 36 | $callback=$attributes["callback"]; |
37 | - if(\is_callable($callback)){ |
|
38 | - $callback($element,$this->_modelInstance,$index); |
|
37 | + if (\is_callable($callback)) { |
|
38 | + $callback($element, $this->_modelInstance, $index); |
|
39 | 39 | unset($attributes["callback"]); |
40 | 40 | } |
41 | 41 | } |
42 | 42 | $element->fromArray($attributes); |
43 | 43 | } |
44 | 44 | |
45 | - protected function _addRules($element,&$attributes){ |
|
46 | - if(isset($attributes["rules"])){ |
|
45 | + protected function _addRules($element, &$attributes) { |
|
46 | + if (isset($attributes["rules"])) { |
|
47 | 47 | $rules=$attributes["rules"]; |
48 | - if(\is_array($rules)){ |
|
48 | + if (\is_array($rules)) { |
|
49 | 49 | $element->addRules($rules); |
50 | 50 | } |
51 | 51 | else |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | } |
55 | 55 | } |
56 | 56 | |
57 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$identifier=null){ |
|
58 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback){ |
|
57 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $identifier=null) { |
|
58 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback){ |
|
59 | 59 | $caption=$this->_instanceViewer->getCaption($index); |
60 | 60 | $name=$this->_instanceViewer->getFieldName($index); |
61 | - $element=$elementCallback($this->getIdentifier()."-".$name,$name,$value,$caption); |
|
62 | - if(\is_array($attributes)){ |
|
63 | - $this->_applyAttributes($element, $attributes,$index); |
|
61 | + $element=$elementCallback($this->getIdentifier()."-".$name, $name, $value, $caption); |
|
62 | + if (\is_array($attributes)) { |
|
63 | + $this->_applyAttributes($element, $attributes, $index); |
|
64 | 64 | } |
65 | 65 | return $element; |
66 | 66 | }); |
@@ -68,53 +68,53 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
72 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
73 | - return new HtmlFormRadio($id,$name,$caption,$value); |
|
74 | - }, $index,$attributes); |
|
71 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
72 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
73 | + return new HtmlFormRadio($id, $name, $caption, $value); |
|
74 | + }, $index, $attributes); |
|
75 | 75 | } |
76 | 76 | |
77 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
78 | - return $this->_fieldAs(function($id,$name,$value,$caption,$elements){ |
|
79 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
80 | - }, $index,$attributes); |
|
77 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
78 | + return $this->_fieldAs(function($id, $name, $value, $caption, $elements) { |
|
79 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
80 | + }, $index, $attributes); |
|
81 | 81 | } |
82 | 82 | |
83 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
84 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
85 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
83 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
84 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
85 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
86 | 86 | $textarea->setName($name); |
87 | 87 | return $textarea; |
88 | - }, $index,$attributes); |
|
88 | + }, $index, $attributes); |
|
89 | 89 | } |
90 | 90 | |
91 | - public function fieldAsInput($index,$attributes=NULL){ |
|
92 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
93 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
91 | + public function fieldAsInput($index, $attributes=NULL) { |
|
92 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
93 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
94 | 94 | $input->setName($name); |
95 | 95 | return $input; |
96 | - }, $index,$attributes); |
|
96 | + }, $index, $attributes); |
|
97 | 97 | } |
98 | 98 | |
99 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
100 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
101 | - return new HtmlFormCheckbox($id,$caption,$value); |
|
102 | - }, $index,$attributes); |
|
99 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
100 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
101 | + return new HtmlFormCheckbox($id, $caption, $value); |
|
102 | + }, $index, $attributes); |
|
103 | 103 | } |
104 | 104 | |
105 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
106 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements,$multiple){ |
|
107 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value,$multiple); |
|
105 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
106 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple){ |
|
107 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value, $multiple); |
|
108 | 108 | $dd->setName($name); |
109 | 109 | return $dd; |
110 | - }, $index,$attributes); |
|
110 | + }, $index, $attributes); |
|
111 | 111 | } |
112 | 112 | |
113 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
114 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
115 | - $mess= new HtmlMessage("message-".$id,$value); |
|
113 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
114 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
115 | + $mess=new HtmlMessage("message-".$id, $value); |
|
116 | 116 | $mess->addHeader($caption); |
117 | 117 | return $mess; |
118 | - }, $index,$attributes,"message"); |
|
118 | + }, $index, $attributes, "message"); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 | \ No newline at end of file |
@@ -47,9 +47,9 @@ |
||
47 | 47 | $rules=$attributes["rules"]; |
48 | 48 | if(\is_array($rules)){ |
49 | 49 | $element->addRules($rules); |
50 | + } else { |
|
51 | + $element->addRule($rules); |
|
50 | 52 | } |
51 | - else |
|
52 | - $element->addRule($rules); |
|
53 | 53 | unset($attributes["rules"]); |
54 | 54 | } |
55 | 55 | } |
@@ -15,111 +15,111 @@ |
||
15 | 15 | * @property InstanceViewer $_instanceViewer |
16 | 16 | */ |
17 | 17 | |
18 | -trait FieldAsTrait{ |
|
18 | +trait FieldAsTrait { |
|
19 | 19 | |
20 | 20 | abstract protected function _getFieldIdentifier($prefix); |
21 | - abstract public function setValueFunction($index,$callback); |
|
21 | + abstract public function setValueFunction($index, $callback); |
|
22 | 22 | |
23 | - private function _getLabelField($caption,$icon=NULL){ |
|
24 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
23 | + private function _getLabelField($caption, $icon=NULL) { |
|
24 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
25 | 25 | return $label; |
26 | 26 | } |
27 | 27 | |
28 | - protected function _addRules($element,&$attributes){} |
|
28 | + protected function _addRules($element, &$attributes) {} |
|
29 | 29 | |
30 | - protected function _fieldAs($elementCallback,$index,$attributes=NULL,$prefix=null){ |
|
31 | - $this->setValueFunction($index,function($value) use ($index,&$attributes,$elementCallback,$prefix){ |
|
30 | + protected function _fieldAs($elementCallback, $index, $attributes=NULL, $prefix=null) { |
|
31 | + $this->setValueFunction($index, function($value) use ($index, &$attributes, $elementCallback, $prefix){ |
|
32 | 32 | $name=$this->_instanceViewer->getCaption($index)."[]"; |
33 | - if(isset($attributes["name"])===true){ |
|
33 | + if (isset($attributes["name"])===true) { |
|
34 | 34 | $name=$attributes["name"]; |
35 | 35 | } |
36 | - $element=$elementCallback($this->_getFieldIdentifier($prefix),$name,$value,""); |
|
37 | - if(\is_array($attributes)) |
|
38 | - $this->_applyAttributes($element, $attributes,$index); |
|
36 | + $element=$elementCallback($this->_getFieldIdentifier($prefix), $name, $value, ""); |
|
37 | + if (\is_array($attributes)) |
|
38 | + $this->_applyAttributes($element, $attributes, $index); |
|
39 | 39 | return $element; |
40 | 40 | }); |
41 | 41 | return $this; |
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
46 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
47 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
45 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
46 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
47 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
48 | 48 | return $pb; |
49 | 49 | }); |
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
53 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
54 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
55 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
53 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
54 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
55 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
56 | 56 | return $rating; |
57 | 57 | }); |
58 | 58 | return $this; |
59 | 59 | } |
60 | 60 | |
61 | - public function fieldAsLabel($index,$icon=NULL){ |
|
62 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
63 | - $lbl=$this->_getLabelField($caption,$icon); |
|
61 | + public function fieldAsLabel($index, $icon=NULL) { |
|
62 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
63 | + $lbl=$this->_getLabelField($caption, $icon); |
|
64 | 64 | return $lbl; |
65 | 65 | }); |
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
69 | - public function fieldAsImage($index,$size=Size::SMALL,$circular=false){ |
|
70 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
71 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
69 | + public function fieldAsImage($index, $size=Size::SMALL, $circular=false) { |
|
70 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
71 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
72 | 72 | return $image; |
73 | 73 | }); |
74 | 74 | return $this; |
75 | 75 | } |
76 | 76 | |
77 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
78 | - return $this->_fieldAs(function($id,$name,$value){ |
|
79 | - $img=new HtmlImage($id,$value); |
|
77 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
78 | + return $this->_fieldAs(function($id, $name, $value) { |
|
79 | + $img=new HtmlImage($id, $value); |
|
80 | 80 | $img->asAvatar(); |
81 | 81 | return $img; |
82 | - }, $index,$attributes,"avatar"); |
|
82 | + }, $index, $attributes, "avatar"); |
|
83 | 83 | } |
84 | 84 | |
85 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
86 | - return $this->_fieldAs(function($id,$name,$value){ |
|
87 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
85 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
86 | + return $this->_fieldAs(function($id, $name, $value) { |
|
87 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
88 | 88 | return $input; |
89 | - }, $index,$attributes,"radio"); |
|
89 | + }, $index, $attributes, "radio"); |
|
90 | 90 | } |
91 | 91 | |
92 | - public function fieldAsInput($index,$attributes=NULL){ |
|
93 | - return $this->_fieldAs(function($id,$name,$value){ |
|
94 | - $input= new HtmlInput($id,"text",$value); |
|
92 | + public function fieldAsInput($index, $attributes=NULL) { |
|
93 | + return $this->_fieldAs(function($id, $name, $value) { |
|
94 | + $input=new HtmlInput($id, "text", $value); |
|
95 | 95 | //TODO check getField |
96 | 96 | $input->setName($name); |
97 | 97 | return $input; |
98 | - }, $index,$attributes,"input"); |
|
98 | + }, $index, $attributes, "input"); |
|
99 | 99 | } |
100 | 100 | |
101 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
102 | - if(\is_array($attributes)===false){ |
|
101 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
102 | + if (\is_array($attributes)===false) { |
|
103 | 103 | $attributes=[]; |
104 | 104 | } |
105 | 105 | $attributes["imputType"]="hidden"; |
106 | - return $this->fieldAsInput($index,$attributes); |
|
106 | + return $this->fieldAsInput($index, $attributes); |
|
107 | 107 | } |
108 | 108 | |
109 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
110 | - return $this->_fieldAs(function($id,$name,$value){ |
|
111 | - $input=new HtmlCheckbox($id,"",$this->_instanceViewer->getIdentifier()); |
|
109 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
110 | + return $this->_fieldAs(function($id, $name, $value) { |
|
111 | + $input=new HtmlCheckbox($id, "", $this->_instanceViewer->getIdentifier()); |
|
112 | 112 | $input->setChecked(JString::isBooleanTrue($value)); |
113 | 113 | $input->getField()->setProperty("name", $name); |
114 | 114 | return $input; |
115 | - }, $index,$attributes,"ck"); |
|
115 | + }, $index, $attributes, "ck"); |
|
116 | 116 | } |
117 | 117 | |
118 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
119 | - return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){ |
|
120 | - $dd=new HtmlDropdown($id,$value,$elements); |
|
121 | - $dd->asSelect($name,$multiple); |
|
118 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
119 | + return $this->_fieldAs(function($id, $name, $value) use($elements, $multiple){ |
|
120 | + $dd=new HtmlDropdown($id, $value, $elements); |
|
121 | + $dd->asSelect($name, $multiple); |
|
122 | 122 | return $dd; |
123 | - }, $index,$attributes,"dd"); |
|
123 | + }, $index, $attributes, "dd"); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | \ No newline at end of file |