@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | trait FieldAsTrait { |
39 | 39 | |
40 | - abstract protected function _getFieldIdentifier($prefix, $name = ""); |
|
40 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
41 | 41 | |
42 | 42 | abstract public function setValueFunction($index, $callback); |
43 | 43 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | abstract protected function _getFieldCaption($index); |
47 | 47 | |
48 | - abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement = NULL, $parameters = NULL); |
|
48 | + abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
49 | 49 | |
50 | 50 | private $_speProperties; |
51 | 51 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param HtmlFormField $element |
55 | 55 | * @param array $attributes |
56 | 56 | */ |
57 | - protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance = null) { |
|
57 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) { |
|
58 | 58 | if (isset($attributes["jsCallback"])) { |
59 | - $callback = $attributes["jsCallback"]; |
|
59 | + $callback=$attributes["jsCallback"]; |
|
60 | 60 | if (\is_callable($callback)) { |
61 | 61 | $callback($element, $instance, $index, InstanceViewer::$index); |
62 | 62 | } |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | $element->fromArray($attributes); |
68 | 68 | } |
69 | 69 | |
70 | - private function _getLabelField($caption, $icon = NULL) { |
|
71 | - $label = new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
70 | + private function _getLabelField($caption, $icon=NULL) { |
|
71 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
72 | 72 | return $label; |
73 | 73 | } |
74 | 74 | |
75 | 75 | protected function _addRules(HtmlFormField $element, &$attributes) { |
76 | 76 | if (isset($attributes["rules"])) { |
77 | - $this->_hasRules = true; |
|
78 | - $rules = $attributes["rules"]; |
|
77 | + $this->_hasRules=true; |
|
78 | + $rules=$attributes["rules"]; |
|
79 | 79 | if (\is_array($rules)) { |
80 | 80 | $element->addRules($rules); |
81 | 81 | } else { |
@@ -91,24 +91,24 @@ discard block |
||
91 | 91 | return $field; |
92 | 92 | } |
93 | 93 | |
94 | - protected function _fieldAs($elementCallback, &$index, $attributes = NULL, $prefix = null) { |
|
95 | - $this->setValueFunction($index, function ($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
96 | - $caption = $this->_getFieldCaption($index); |
|
97 | - $name = $this->_getFieldName($index); |
|
98 | - $id = $this->_getFieldIdentifier($prefix, $name); |
|
94 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
95 | + $this->setValueFunction($index, function($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
96 | + $caption=$this->_getFieldCaption($index); |
|
97 | + $name=$this->_getFieldName($index); |
|
98 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
99 | 99 | if (isset($attributes["name"])) { |
100 | - $name = $attributes["name"]; |
|
100 | + $name=$attributes["name"]; |
|
101 | 101 | unset($attributes["name"]); |
102 | 102 | } |
103 | - $element = $elementCallback($id, $name, $value, $caption); |
|
103 | + $element=$elementCallback($id, $name, $value, $caption); |
|
104 | 104 | if (isset($this->_speProperties[$index])) { |
105 | 105 | $attributes ??= []; |
106 | - $attributes += $this->_speProperties[$index]; |
|
106 | + $attributes+=$this->_speProperties[$index]; |
|
107 | 107 | } |
108 | 108 | if (\is_array($attributes)) { |
109 | 109 | $this->_applyAttributes($element, $attributes, $index, $instance); |
110 | 110 | } |
111 | - $element->setDisabled(! $this->_edition); |
|
111 | + $element->setDisabled(!$this->_edition); |
|
112 | 112 | return $element; |
113 | 113 | }); |
114 | 114 | return $this; |
@@ -124,48 +124,48 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function setPropertyValues($property, $indexValues) { |
126 | 126 | foreach ($indexValues as $index => $value) { |
127 | - $ind = $this->_getIndex($index); |
|
128 | - $this->_speProperties[$ind][$property] = $value; |
|
127 | + $ind=$this->_getIndex($index); |
|
128 | + $this->_speProperties[$ind][$property]=$value; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | - public function fieldAsProgress($index, $label = NULL, $attributes = array()) { |
|
133 | - $this->setValueFunction($index, function ($value) use ($label, $attributes) { |
|
134 | - $pb = new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
132 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
133 | + $this->setValueFunction($index, function($value) use ($label, $attributes) { |
|
134 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
135 | 135 | return $pb; |
136 | 136 | }); |
137 | 137 | return $this; |
138 | 138 | } |
139 | 139 | |
140 | - public function fieldAsRating($index, $max = 5, $icon = "") { |
|
141 | - $this->setValueFunction($index, function ($value) use ($max, $icon) { |
|
142 | - $rating = new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
140 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
141 | + $this->setValueFunction($index, function($value) use ($max, $icon) { |
|
142 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
143 | 143 | return $rating; |
144 | 144 | }); |
145 | 145 | return $this; |
146 | 146 | } |
147 | 147 | |
148 | - public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) { |
|
149 | - return $this->_fieldAs(function ($id, $name, $value) use ($icon) { |
|
150 | - $lbl = new HtmlLabel($id, $value); |
|
148 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
149 | + return $this->_fieldAs(function($id, $name, $value) use ($icon) { |
|
150 | + $lbl=new HtmlLabel($id, $value); |
|
151 | 151 | if (isset($icon)) |
152 | 152 | $lbl->addIcon($icon); |
153 | 153 | return $lbl; |
154 | 154 | }, $index, $attributes, "label"); |
155 | 155 | } |
156 | 156 | |
157 | - public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) { |
|
158 | - return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) { |
|
159 | - $header = new HtmlHeader($id, $niveau, $value); |
|
157 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
158 | + return $this->_fieldAs(function($id, $name, $value) use ($niveau, $icon) { |
|
159 | + $header=new HtmlHeader($id, $niveau, $value); |
|
160 | 160 | if (isset($icon)) |
161 | 161 | $header->asIcon($icon, $value); |
162 | 162 | return $header; |
163 | 163 | }, $index, $attributes, "header"); |
164 | 164 | } |
165 | 165 | |
166 | - public function fieldAsImage($index, $size = Size::MINI, $circular = false) { |
|
167 | - $this->setValueFunction($index, function ($img) use ($size, $circular) { |
|
168 | - $image = new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
166 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
167 | + $this->setValueFunction($index, function($img) use ($size, $circular) { |
|
168 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
169 | 169 | $image->setSize($size); |
170 | 170 | if ($circular) |
171 | 171 | $image->setCircular(); |
@@ -175,65 +175,65 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | public function fieldAsFlag($index) { |
178 | - $this->setValueFunction($index, function ($flag) { |
|
179 | - $flag = new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
178 | + $this->setValueFunction($index, function($flag) { |
|
179 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
180 | 180 | return $flag; |
181 | 181 | }); |
182 | 182 | return $this; |
183 | 183 | } |
184 | 184 | |
185 | 185 | public function fieldAsIcon($index) { |
186 | - $this->setValueFunction($index, function ($icon) { |
|
187 | - $icon = new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
186 | + $this->setValueFunction($index, function($icon) { |
|
187 | + $icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
188 | 188 | return $icon; |
189 | 189 | }); |
190 | 190 | return $this; |
191 | 191 | } |
192 | 192 | |
193 | - public function fieldAsAvatar($index, $attributes = NULL) { |
|
194 | - return $this->_fieldAs(function ($id, $name, $value) { |
|
195 | - $img = new HtmlImage($id, $value); |
|
193 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
194 | + return $this->_fieldAs(function($id, $name, $value) { |
|
195 | + $img=new HtmlImage($id, $value); |
|
196 | 196 | $img->asAvatar(); |
197 | 197 | return $img; |
198 | 198 | }, $index, $attributes, "avatar"); |
199 | 199 | } |
200 | 200 | |
201 | - public function fieldAsRadio($index, $attributes = NULL) { |
|
202 | - return $this->_fieldAs(function ($id, $name, $value) use ($attributes) { |
|
203 | - $input = new HtmlFormRadio($id, $name, $value, $value); |
|
201 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
202 | + return $this->_fieldAs(function($id, $name, $value) use ($attributes) { |
|
203 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
204 | 204 | return $this->_prepareFormFields($input, $name, $attributes); |
205 | 205 | }, $index, $attributes, "radio"); |
206 | 206 | } |
207 | 207 | |
208 | - public function fieldAsRadios($index, $elements = [], $attributes = NULL) { |
|
209 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements) { |
|
208 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
209 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements) { |
|
210 | 210 | return HtmlFormFields::radios($name, $elements, $caption, $value); |
211 | 211 | }, $index, $attributes, "radios"); |
212 | 212 | } |
213 | 213 | |
214 | - public function fieldAsList($index, $classNames = "", $attributes = NULL) { |
|
215 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($classNames) { |
|
216 | - $result = new HtmlList($name, $value); |
|
214 | + public function fieldAsList($index, $classNames="", $attributes=NULL) { |
|
215 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($classNames) { |
|
216 | + $result=new HtmlList($name, $value); |
|
217 | 217 | $result->addClass($classNames); |
218 | 218 | return $result; |
219 | 219 | }, $index, $attributes, "list"); |
220 | 220 | } |
221 | 221 | |
222 | - public function fieldAsInput($index, $attributes = NULL) { |
|
223 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
224 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
222 | + public function fieldAsInput($index, $attributes=NULL) { |
|
223 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
224 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
225 | 225 | return $this->_prepareFormFields($input, $name, $attributes); |
226 | 226 | }, $index, $attributes, "input"); |
227 | 227 | } |
228 | 228 | |
229 | - public function fieldAsLabeledInput($index, $attributes = NULL) { |
|
230 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
231 | - $input = new HtmlFormInput($id, '', 'text', $value, $caption); |
|
232 | - $required = ''; |
|
229 | + public function fieldAsLabeledInput($index, $attributes=NULL) { |
|
230 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
231 | + $input=new HtmlFormInput($id, '', 'text', $value, $caption); |
|
232 | + $required=''; |
|
233 | 233 | if (isset($attributes['rules'])) { |
234 | - $rules = json_encode($attributes['rules']); |
|
235 | - if (strpos($rules, 'empty') !== false) { |
|
236 | - $required = 'required'; |
|
234 | + $rules=json_encode($attributes['rules']); |
|
235 | + if (strpos($rules, 'empty')!==false) { |
|
236 | + $required='required'; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | $input->getField() |
@@ -244,80 +244,80 @@ discard block |
||
244 | 244 | }, $index, $attributes, 'input'); |
245 | 245 | } |
246 | 246 | |
247 | - public function fieldAsDataList($index, ?array $items = [], $attributes = NULL) { |
|
248 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $items) { |
|
249 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
247 | + public function fieldAsDataList($index, ?array $items=[], $attributes=NULL) { |
|
248 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $items) { |
|
249 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
250 | 250 | $input->getField() |
251 | 251 | ->addDataList($items); |
252 | 252 | return $this->_prepareFormFields($input, $name, $attributes); |
253 | 253 | }, $index, $attributes, "input"); |
254 | 254 | } |
255 | 255 | |
256 | - public function fieldAsFile($index, $attributes = NULL) { |
|
256 | + public function fieldAsFile($index, $attributes=NULL) { |
|
257 | 257 | if (isset($this->_form)) { |
258 | 258 | $this->_form->setProperty('enctype', 'multipart/form-data'); |
259 | 259 | } |
260 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
261 | - $input = new HtmlFormInput($id, $caption); |
|
260 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
261 | + $input=new HtmlFormInput($id, $caption); |
|
262 | 262 | $input->asFile(); |
263 | 263 | return $this->_prepareFormFields($input, $name, $attributes); |
264 | 264 | }, $index, $attributes, "input"); |
265 | 265 | } |
266 | 266 | |
267 | - public function fieldAsTextarea($index, $attributes = NULL) { |
|
268 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
269 | - $textarea = new HtmlFormTextarea($id, $caption, $value); |
|
267 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
268 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
269 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
270 | 270 | return $this->_prepareFormFields($textarea, $name, $attributes); |
271 | 271 | }, $index, $attributes, "textarea"); |
272 | 272 | } |
273 | 273 | |
274 | - public function fieldAsElement($index, $tagName = "div", $baseClass = "", $attributes = NULL) { |
|
275 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
276 | - $div = new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
274 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
275 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
276 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
277 | 277 | $div->setContent(\htmlentities($value)); |
278 | - $textarea = new HtmlFormField("field-" . $id, $div, $caption); |
|
278 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
279 | 279 | return $this->_prepareFormFields($textarea, $name, $attributes); |
280 | 280 | }, $index, $attributes, "element"); |
281 | 281 | } |
282 | 282 | |
283 | - public function fieldAsHidden($index, $attributes = NULL) { |
|
284 | - if (! \is_array($attributes)) { |
|
285 | - $attributes = []; |
|
283 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
284 | + if (!\is_array($attributes)) { |
|
285 | + $attributes=[]; |
|
286 | 286 | } |
287 | - $attributes["inputType"] = "hidden"; |
|
288 | - $attributes["style"] = "display:none;"; |
|
287 | + $attributes["inputType"]="hidden"; |
|
288 | + $attributes["style"]="display:none;"; |
|
289 | 289 | return $this->fieldAsInput($index, $attributes); |
290 | 290 | } |
291 | 291 | |
292 | - public function fieldAsCheckbox($index, $attributes = NULL) { |
|
293 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
294 | - if ($caption === null || $caption === "") |
|
295 | - $caption = ""; |
|
296 | - $input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
292 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
293 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
294 | + if ($caption===null || $caption==="") |
|
295 | + $caption=""; |
|
296 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
297 | 297 | $input->setChecked(JString::isBooleanTrue($value)); |
298 | 298 | return $this->_prepareFormFields($input, $name, $attributes); |
299 | 299 | }, $index, $attributes, "ck"); |
300 | 300 | } |
301 | 301 | |
302 | - public function fieldAsDropDown($index, $elements = [], $multiple = false, $attributes = NULL) { |
|
303 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
304 | - $dd = new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
302 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
303 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
304 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
305 | 305 | $dd->asSelect($name, $multiple); |
306 | 306 | return $this->_prepareFormFields($dd, $name, $attributes); |
307 | 307 | }, $index, $attributes, "dd"); |
308 | 308 | } |
309 | 309 | |
310 | - public function fieldAsMessage($index, $attributes = NULL) { |
|
311 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
312 | - $mess = new HtmlMessage("message-" . $id, $caption); |
|
310 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
311 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
312 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
313 | 313 | $mess->addHeader($value); |
314 | 314 | return $mess; |
315 | 315 | }, $index, $attributes, "message"); |
316 | 316 | } |
317 | 317 | |
318 | - public function fieldAsLink($index, $attributes = NULL) { |
|
319 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
320 | - $lnk = new HtmlLink("message-" . $id, "#", $caption); |
|
318 | + public function fieldAsLink($index, $attributes=NULL) { |
|
319 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
320 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
321 | 321 | return $lnk; |
322 | 322 | }, $index, $attributes, "link"); |
323 | 323 | } |
@@ -329,28 +329,28 @@ discard block |
||
329 | 329 | * an array or associative array $type=>$attributes |
330 | 330 | */ |
331 | 331 | public function fieldsAs(array $types) { |
332 | - $i = 0; |
|
332 | + $i=0; |
|
333 | 333 | if (JArray::isAssociative($types)) { |
334 | 334 | foreach ($types as $type => $attributes) { |
335 | 335 | if (\is_int($type)) |
336 | - $this->fieldAs($i ++, $attributes, []); |
|
336 | + $this->fieldAs($i++, $attributes, []); |
|
337 | 337 | else { |
338 | - $type = preg_replace('/\d/', '', $type); |
|
339 | - $this->fieldAs($i ++, $type, $attributes); |
|
338 | + $type=preg_replace('/\d/', '', $type); |
|
339 | + $this->fieldAs($i++, $type, $attributes); |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | } else { |
343 | 343 | foreach ($types as $type) { |
344 | - $this->fieldAs($i ++, $type); |
|
344 | + $this->fieldAs($i++, $type); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | - public function fieldAs($index, $type, $attributes = NULL) { |
|
350 | - $method = "fieldAs" . \ucfirst($type); |
|
349 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
350 | + $method="fieldAs".\ucfirst($type); |
|
351 | 351 | if (\method_exists($this, $method)) { |
352 | - if (! \is_array($attributes)) { |
|
353 | - $attributes = [ |
|
352 | + if (!\is_array($attributes)) { |
|
353 | + $attributes=[ |
|
354 | 354 | $index |
355 | 355 | ]; |
356 | 356 | } else { |
@@ -363,39 +363,39 @@ discard block |
||
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
366 | - public function fieldAsSubmit($index, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $attributes = NULL) { |
|
367 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
368 | - $button = new HtmlButton($id, $caption, $cssStyle); |
|
366 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
367 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
368 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
369 | 369 | $this->_buttonAsSubmit($button, "click", $url, $responseElement, $attributes["ajax"] ?? []); |
370 | 370 | return $button; |
371 | 371 | }, $index, $attributes, "submit"); |
372 | 372 | } |
373 | 373 | |
374 | - public function fieldAsButton($index, $cssStyle = NULL, $attributes = NULL) { |
|
375 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($cssStyle) { |
|
376 | - $button = new HtmlButton($id, $value, $cssStyle); |
|
374 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
375 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle) { |
|
376 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
377 | 377 | return $button; |
378 | 378 | }, $index, $attributes, "button"); |
379 | 379 | } |
380 | 380 | |
381 | - public function fieldAsDataTable($index, $model, $instances = null, $fields = [], $attributes = NULL) { |
|
382 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($model, $instances, $fields, $index) { |
|
383 | - $dt = new DataTable($id, $model, $instances); |
|
381 | + public function fieldAsDataTable($index, $model, $instances=null, $fields=[], $attributes=NULL) { |
|
382 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($model, $instances, $fields, $index) { |
|
383 | + $dt=new DataTable($id, $model, $instances); |
|
384 | 384 | $dt->setNamePrefix($index); |
385 | 385 | $dt->setFields($fields); |
386 | 386 | $dt->setEdition(true); |
387 | - $dt->addDeleteButton(false, [], function ($bt) use ($index) { |
|
387 | + $dt->addDeleteButton(false, [], function($bt) use ($index) { |
|
388 | 388 | $bt->addClass('mini circular') |
389 | - ->wrap('<input value="" class="_status" type="hidden" name="' . $index . '._status[]">'); |
|
389 | + ->wrap('<input value="" class="_status" type="hidden" name="'.$index.'._status[]">'); |
|
390 | 390 | }); |
391 | - if ($caption != null) { |
|
391 | + if ($caption!=null) { |
|
392 | 392 | $dt->setFormCaption($caption); |
393 | 393 | } |
394 | - $dt->onPreCompile(function () use (&$dt) { |
|
394 | + $dt->onPreCompile(function() use (&$dt) { |
|
395 | 395 | $dt->getHtmlComponent() |
396 | 396 | ->colRightFromRight(0); |
397 | 397 | }); |
398 | - $dt->wrap('<input type="hidden" name="' . $index . '">'); |
|
398 | + $dt->wrap('<input type="hidden" name="'.$index.'">'); |
|
399 | 399 | return $dt; |
400 | 400 | }, $index, $attributes, "dataTable"); |
401 | 401 | } |