@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public function __construct($App) |
| 63 | 63 | { |
| 64 | 64 | $this->Request = $App->Request(); |
| 65 | - $formErrors = $App->get('errors',[]); |
|
| 65 | + $formErrors = $App->get('errors', []); |
|
| 66 | 66 | is_array($formErrors) OR $formErrors = [$formErrors]; |
| 67 | 67 | $this->Errors = new Collection($formErrors); |
| 68 | 68 | } |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | * @param array $attributes |
| 73 | 73 | * @return $this |
| 74 | 74 | */ |
| 75 | - public function addAudio($label,$attributes=[]) |
|
| 75 | + public function addAudio($label, $attributes = []) |
|
| 76 | 76 | { |
| 77 | - if($this->Form instanceof form) |
|
| 77 | + if ($this->Form instanceof form) |
|
| 78 | 78 | { |
| 79 | - $item = new Audio($label,$attributes); |
|
| 80 | - $item->Attributes()->set('accept','audio/*'); |
|
| 79 | + $item = new Audio($label, $attributes); |
|
| 80 | + $item->Attributes()->set('accept', 'audio/*'); |
|
| 81 | 81 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 82 | - $this->Form->Attributes()->set('enctype','multipart/form-data'); |
|
| 82 | + $this->Form->Attributes()->set('enctype', 'multipart/form-data'); |
|
| 83 | 83 | $this->Form->append($item); |
| 84 | 84 | } |
| 85 | 85 | return $this; |
@@ -90,11 +90,11 @@ discard block |
||
| 90 | 90 | * @param array $attributes |
| 91 | 91 | * @return $this |
| 92 | 92 | */ |
| 93 | - public function addButton($label,$attributes=[]) |
|
| 93 | + public function addButton($label, $attributes = []) |
|
| 94 | 94 | { |
| 95 | - if($this->Form instanceof form) |
|
| 95 | + if ($this->Form instanceof form) |
|
| 96 | 96 | { |
| 97 | - $item = new Button($label,$attributes); |
|
| 97 | + $item = new Button($label, $attributes); |
|
| 98 | 98 | $this->Form->append($item); |
| 99 | 99 | } |
| 100 | 100 | return $this; |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | * @param array $attributes |
| 106 | 106 | * @return $this |
| 107 | 107 | */ |
| 108 | - public function addCaptcha($label,$attributes=[]) |
|
| 108 | + public function addCaptcha($label, $attributes = []) |
|
| 109 | 109 | { |
| 110 | - if($this->Form instanceof form) |
|
| 110 | + if ($this->Form instanceof form) |
|
| 111 | 111 | { |
| 112 | - $item = new Captcha($label,$attributes); |
|
| 112 | + $item = new Captcha($label, $attributes); |
|
| 113 | 113 | //$this->Request->getSession()->set(md5($item->Attributes()->get('name')), $item->Attributes()->get('capresponse')); |
| 114 | 114 | // $this->Request->Session->set(md5($item->Attributes()->get('name')),$item->Attributes()->get('capresponse')); |
| 115 | 115 | $this->Form->append($item); |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | * @param array $attributes |
| 124 | 124 | * @return $this |
| 125 | 125 | */ |
| 126 | - public function addCheckbox($label,$options = [],$attributes=[]) |
|
| 126 | + public function addCheckbox($label, $options = [], $attributes = []) |
|
| 127 | 127 | { |
| 128 | - if($this->Form instanceof form) |
|
| 128 | + if ($this->Form instanceof form) |
|
| 129 | 129 | { |
| 130 | - $item = new Checkbox($label,$options ,$attributes); |
|
| 130 | + $item = new Checkbox($label, $options, $attributes); |
|
| 131 | 131 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 132 | 132 | $this->Form->append($item); |
| 133 | 133 | } |
@@ -139,11 +139,11 @@ discard block |
||
| 139 | 139 | * @param array $attributes |
| 140 | 140 | * @return $this |
| 141 | 141 | */ |
| 142 | - public function addColor($label,$attributes=[]) |
|
| 142 | + public function addColor($label, $attributes = []) |
|
| 143 | 143 | { |
| 144 | - if($this->Form instanceof form) |
|
| 144 | + if ($this->Form instanceof form) |
|
| 145 | 145 | { |
| 146 | - $item = new Color($label,$attributes); |
|
| 146 | + $item = new Color($label, $attributes); |
|
| 147 | 147 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 148 | 148 | $this->Form->append($item); |
| 149 | 149 | } |
@@ -155,11 +155,11 @@ discard block |
||
| 155 | 155 | * @param array $attributes |
| 156 | 156 | * @return $this |
| 157 | 157 | */ |
| 158 | - public function addCountries($label,$attributes=[]) |
|
| 158 | + public function addCountries($label, $attributes = []) |
|
| 159 | 159 | { |
| 160 | - if($this->Form instanceof form) |
|
| 160 | + if ($this->Form instanceof form) |
|
| 161 | 161 | { |
| 162 | - $item = new Country($label,$attributes); |
|
| 162 | + $item = new Country($label, $attributes); |
|
| 163 | 163 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 164 | 164 | $this->Form->append($item); |
| 165 | 165 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param array $attributes |
| 171 | 171 | * @return $this |
| 172 | 172 | */ |
| 173 | - public function addDatalist($label, $options=[], $attributes = []) |
|
| 173 | + public function addDatalist($label, $options = [], $attributes = []) |
|
| 174 | 174 | { |
| 175 | 175 | if ($this->Form instanceof form) { |
| 176 | 176 | $item = new Datalist($label, $options, $attributes); |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | * @param array $attributes |
| 186 | 186 | * @return $this |
| 187 | 187 | */ |
| 188 | - public function addDate($label,$attributes=[]) |
|
| 188 | + public function addDate($label, $attributes = []) |
|
| 189 | 189 | { |
| 190 | - if($this->Form instanceof form) |
|
| 190 | + if ($this->Form instanceof form) |
|
| 191 | 191 | { |
| 192 | - $item = new Date($label,$attributes); |
|
| 192 | + $item = new Date($label, $attributes); |
|
| 193 | 193 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 194 | 194 | $this->Form->append($item); |
| 195 | 195 | } |
@@ -201,11 +201,11 @@ discard block |
||
| 201 | 201 | * @param array $attributes |
| 202 | 202 | * @return $this |
| 203 | 203 | */ |
| 204 | - public function addDatetime($label,$attributes=[]) |
|
| 204 | + public function addDatetime($label, $attributes = []) |
|
| 205 | 205 | { |
| 206 | - if($this->Form instanceof form) |
|
| 206 | + if ($this->Form instanceof form) |
|
| 207 | 207 | { |
| 208 | - $item = new Datetime($label,$attributes); |
|
| 208 | + $item = new Datetime($label, $attributes); |
|
| 209 | 209 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 210 | 210 | $this->Form->append($item); |
| 211 | 211 | } |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | * @param array $attributes |
| 218 | 218 | * @return $this |
| 219 | 219 | */ |
| 220 | - public function addDatetimeLocal($label,$attributes=[]) |
|
| 220 | + public function addDatetimeLocal($label, $attributes = []) |
|
| 221 | 221 | { |
| 222 | - if($this->Form instanceof form) |
|
| 222 | + if ($this->Form instanceof form) |
|
| 223 | 223 | { |
| 224 | - $item = new DatetimeLocal($label,$attributes); |
|
| 224 | + $item = new DatetimeLocal($label, $attributes); |
|
| 225 | 225 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 226 | 226 | $this->Form->append($item); |
| 227 | 227 | } |
@@ -232,11 +232,11 @@ discard block |
||
| 232 | 232 | * @param array $attributes |
| 233 | 233 | * @return $this |
| 234 | 234 | */ |
| 235 | - public function addEditor($label,$attributes=[]) |
|
| 235 | + public function addEditor($label, $attributes = []) |
|
| 236 | 236 | { |
| 237 | - if($this->Form instanceof form) |
|
| 237 | + if ($this->Form instanceof form) |
|
| 238 | 238 | { |
| 239 | - $item = new Editor($label,$attributes); |
|
| 239 | + $item = new Editor($label, $attributes); |
|
| 240 | 240 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 241 | 241 | $this->Form->append($item); |
| 242 | 242 | } |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | * @param array $attributes |
| 248 | 248 | * @return $this |
| 249 | 249 | */ |
| 250 | - public function addEmail($label,$attributes=[]) |
|
| 250 | + public function addEmail($label, $attributes = []) |
|
| 251 | 251 | { |
| 252 | - if($this->Form instanceof form) |
|
| 252 | + if ($this->Form instanceof form) |
|
| 253 | 253 | { |
| 254 | - $item = new Email($label,$attributes); |
|
| 254 | + $item = new Email($label, $attributes); |
|
| 255 | 255 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 256 | 256 | $this->Form->append($item); |
| 257 | 257 | } |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | * @param array $attributes |
| 262 | 262 | * @return $this |
| 263 | 263 | */ |
| 264 | - public function addFieldset($attributes=[]) |
|
| 264 | + public function addFieldset($attributes = []) |
|
| 265 | 265 | { |
| 266 | - if($this->Form instanceof form) |
|
| 266 | + if ($this->Form instanceof form) |
|
| 267 | 267 | { |
| 268 | - if($this->Fieldset instanceof fieldsetGenerator) |
|
| 268 | + if ($this->Fieldset instanceof fieldsetGenerator) |
|
| 269 | 269 | $this->Form->append($this->Fieldset->Close()); |
| 270 | 270 | $this->Fieldset = new fieldsetGenerator($attributes); |
| 271 | 271 | $this->Fieldset->Attributes()->set('name', $this->Form->Attributes()->get('name')); |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | * @param array $attributes |
| 279 | 279 | * @return $this |
| 280 | 280 | */ |
| 281 | - public function addFile($label,$attributes=[]) |
|
| 281 | + public function addFile($label, $attributes = []) |
|
| 282 | 282 | { |
| 283 | - if($this->Form instanceof form) |
|
| 283 | + if ($this->Form instanceof form) |
|
| 284 | 284 | { |
| 285 | - $item = new File($label,$attributes); |
|
| 286 | - $this->Form->Attributes()->set('enctype','multipart/form-data'); |
|
| 285 | + $item = new File($label, $attributes); |
|
| 286 | + $this->Form->Attributes()->set('enctype', 'multipart/form-data'); |
|
| 287 | 287 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 288 | 288 | $this->Form->append($item); |
| 289 | 289 | } |
@@ -295,11 +295,11 @@ discard block |
||
| 295 | 295 | * @param array $attributes |
| 296 | 296 | * @return $this |
| 297 | 297 | */ |
| 298 | - public function addHidden($label,$attributes=[]) |
|
| 298 | + public function addHidden($label, $attributes = []) |
|
| 299 | 299 | { |
| 300 | - if($this->Form instanceof form) |
|
| 300 | + if ($this->Form instanceof form) |
|
| 301 | 301 | { |
| 302 | - $item = new Hidden($label,$attributes); |
|
| 302 | + $item = new Hidden($label, $attributes); |
|
| 303 | 303 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 304 | 304 | $this->Form->append($item); |
| 305 | 305 | } |
@@ -312,9 +312,9 @@ discard block |
||
| 312 | 312 | */ |
| 313 | 313 | public function addHtml($html) |
| 314 | 314 | { |
| 315 | - if($this->Form instanceof form) |
|
| 315 | + if ($this->Form instanceof form) |
|
| 316 | 316 | { |
| 317 | - if(gettype($html) === 'string') |
|
| 317 | + if (gettype($html) === 'string') |
|
| 318 | 318 | $this->Form->append($html); |
| 319 | 319 | } |
| 320 | 320 | return $this; |
@@ -325,12 +325,12 @@ discard block |
||
| 325 | 325 | * @param array $attributes |
| 326 | 326 | * @return $this |
| 327 | 327 | */ |
| 328 | - public function addImage($label,$attributes=[]) |
|
| 328 | + public function addImage($label, $attributes = []) |
|
| 329 | 329 | { |
| 330 | - if($this->Form instanceof form) |
|
| 330 | + if ($this->Form instanceof form) |
|
| 331 | 331 | { |
| 332 | - $item = new Image($label,$attributes); |
|
| 333 | - $this->Form->Attributes()->set('enctype','multipart/form-data'); |
|
| 332 | + $item = new Image($label, $attributes); |
|
| 333 | + $this->Form->Attributes()->set('enctype', 'multipart/form-data'); |
|
| 334 | 334 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 335 | 335 | $this->Form->append($item); |
| 336 | 336 | } |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | * @param array $attributes |
| 343 | 343 | * @return $this |
| 344 | 344 | */ |
| 345 | - public function addMonth($label,$attributes=[]) |
|
| 345 | + public function addMonth($label, $attributes = []) |
|
| 346 | 346 | { |
| 347 | - if($this->Form instanceof form) |
|
| 347 | + if ($this->Form instanceof form) |
|
| 348 | 348 | { |
| 349 | - $item = new Month($label,$attributes); |
|
| 349 | + $item = new Month($label, $attributes); |
|
| 350 | 350 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 351 | 351 | $this->Form->append($item); |
| 352 | 352 | } |
@@ -358,11 +358,11 @@ discard block |
||
| 358 | 358 | * @param array $attributes |
| 359 | 359 | * @return $this |
| 360 | 360 | */ |
| 361 | - public function addNumber($label,$attributes=[]) |
|
| 361 | + public function addNumber($label, $attributes = []) |
|
| 362 | 362 | { |
| 363 | - if($this->Form instanceof form) |
|
| 363 | + if ($this->Form instanceof form) |
|
| 364 | 364 | { |
| 365 | - $item = new Number($label,$attributes); |
|
| 365 | + $item = new Number($label, $attributes); |
|
| 366 | 366 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 367 | 367 | $this->Form->append($item); |
| 368 | 368 | } |
@@ -373,11 +373,11 @@ discard block |
||
| 373 | 373 | * @param array $attributes |
| 374 | 374 | * @return $this |
| 375 | 375 | */ |
| 376 | - public function addPassword($label,$attributes=[]) |
|
| 376 | + public function addPassword($label, $attributes = []) |
|
| 377 | 377 | { |
| 378 | - if($this->Form instanceof form) |
|
| 378 | + if ($this->Form instanceof form) |
|
| 379 | 379 | { |
| 380 | - $item = new Password($label,$attributes); |
|
| 380 | + $item = new Password($label, $attributes); |
|
| 381 | 381 | $item->Attributes()->set('value', ''); |
| 382 | 382 | $this->Form->append($item); |
| 383 | 383 | } |
@@ -389,11 +389,11 @@ discard block |
||
| 389 | 389 | * @param array $attributes |
| 390 | 390 | * @return $this |
| 391 | 391 | */ |
| 392 | - public function addPhone($label,$attributes=[]) |
|
| 392 | + public function addPhone($label, $attributes = []) |
|
| 393 | 393 | { |
| 394 | - if($this->Form instanceof form) |
|
| 394 | + if ($this->Form instanceof form) |
|
| 395 | 395 | { |
| 396 | - $item = new Phone($label,$attributes); |
|
| 396 | + $item = new Phone($label, $attributes); |
|
| 397 | 397 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 398 | 398 | $this->Form->append($item); |
| 399 | 399 | } |
@@ -406,11 +406,11 @@ discard block |
||
| 406 | 406 | * @param array $attributes |
| 407 | 407 | * @return $this |
| 408 | 408 | */ |
| 409 | - public function addRadio($label,$options=[],$attributes=[]) |
|
| 409 | + public function addRadio($label, $options = [], $attributes = []) |
|
| 410 | 410 | { |
| 411 | - if($this->Form instanceof form) |
|
| 411 | + if ($this->Form instanceof form) |
|
| 412 | 412 | { |
| 413 | - $item = new Radio($label,$options,$attributes); |
|
| 413 | + $item = new Radio($label, $options, $attributes); |
|
| 414 | 414 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 415 | 415 | $this->Form->append($item); |
| 416 | 416 | } |
@@ -422,11 +422,11 @@ discard block |
||
| 422 | 422 | * @param array $attributes |
| 423 | 423 | * @return $this |
| 424 | 424 | */ |
| 425 | - public function addRange($label,$attributes=[]) |
|
| 425 | + public function addRange($label, $attributes = []) |
|
| 426 | 426 | { |
| 427 | - if($this->Form instanceof form) |
|
| 427 | + if ($this->Form instanceof form) |
|
| 428 | 428 | { |
| 429 | - $item = new Range($label,$attributes); |
|
| 429 | + $item = new Range($label, $attributes); |
|
| 430 | 430 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 431 | 431 | $this->Form->append($item); |
| 432 | 432 | } |
@@ -438,11 +438,11 @@ discard block |
||
| 438 | 438 | * @param array $attributes |
| 439 | 439 | * @return $this |
| 440 | 440 | */ |
| 441 | - public function addReset($label,$attributes=[]) |
|
| 441 | + public function addReset($label, $attributes = []) |
|
| 442 | 442 | { |
| 443 | - if($this->Form instanceof form) |
|
| 443 | + if ($this->Form instanceof form) |
|
| 444 | 444 | { |
| 445 | - $item = new Reset($label,$attributes); |
|
| 445 | + $item = new Reset($label, $attributes); |
|
| 446 | 446 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 447 | 447 | $this->Form->append($item); |
| 448 | 448 | } |
@@ -454,11 +454,11 @@ discard block |
||
| 454 | 454 | * @param array $attributes |
| 455 | 455 | * @return $this |
| 456 | 456 | */ |
| 457 | - public function addSearch($label,$attributes=[]) |
|
| 457 | + public function addSearch($label, $attributes = []) |
|
| 458 | 458 | { |
| 459 | - if($this->Form instanceof form) |
|
| 459 | + if ($this->Form instanceof form) |
|
| 460 | 460 | { |
| 461 | - $item = new Search($label,$attributes); |
|
| 461 | + $item = new Search($label, $attributes); |
|
| 462 | 462 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 463 | 463 | $this->Form->append($item); |
| 464 | 464 | } |
@@ -470,11 +470,11 @@ discard block |
||
| 470 | 470 | * @param array $attributes |
| 471 | 471 | * @return $this |
| 472 | 472 | */ |
| 473 | - public function addSelect($label,array $options = [],$attributes=[]) |
|
| 473 | + public function addSelect($label, array $options = [], $attributes = []) |
|
| 474 | 474 | { |
| 475 | - if($this->Form instanceof form) |
|
| 475 | + if ($this->Form instanceof form) |
|
| 476 | 476 | { |
| 477 | - $item = new Select($label,$options,$attributes); |
|
| 477 | + $item = new Select($label, $options, $attributes); |
|
| 478 | 478 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 479 | 479 | $this->Form->append($item); |
| 480 | 480 | } |
@@ -485,11 +485,11 @@ discard block |
||
| 485 | 485 | * @param array $attributes |
| 486 | 486 | * @return $this |
| 487 | 487 | */ |
| 488 | - public function addSubmit($label,$attributes=[]) |
|
| 488 | + public function addSubmit($label, $attributes = []) |
|
| 489 | 489 | { |
| 490 | - if($this->Form instanceof form) |
|
| 490 | + if ($this->Form instanceof form) |
|
| 491 | 491 | { |
| 492 | - $item = new Submit($label,$attributes); |
|
| 492 | + $item = new Submit($label, $attributes); |
|
| 493 | 493 | $this->Form->append($item); |
| 494 | 494 | } |
| 495 | 495 | return $this; |
@@ -500,11 +500,11 @@ discard block |
||
| 500 | 500 | * @param array $attributes |
| 501 | 501 | * @return $this |
| 502 | 502 | */ |
| 503 | - public function addText($label,$attributes=[]) |
|
| 503 | + public function addText($label, $attributes = []) |
|
| 504 | 504 | { |
| 505 | - if($this->Form instanceof form) |
|
| 505 | + if ($this->Form instanceof form) |
|
| 506 | 506 | { |
| 507 | - $item = new Text($label,$attributes); |
|
| 507 | + $item = new Text($label, $attributes); |
|
| 508 | 508 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 509 | 509 | $this->Form->append($item); |
| 510 | 510 | } |
@@ -516,11 +516,11 @@ discard block |
||
| 516 | 516 | * @param array $attributes |
| 517 | 517 | * @return $this |
| 518 | 518 | */ |
| 519 | - public function addTextarea($label,$attributes=[]) |
|
| 519 | + public function addTextarea($label, $attributes = []) |
|
| 520 | 520 | { |
| 521 | - if($this->Form instanceof form) |
|
| 521 | + if ($this->Form instanceof form) |
|
| 522 | 522 | { |
| 523 | - $item = new Textarea($label,$attributes); |
|
| 523 | + $item = new Textarea($label, $attributes); |
|
| 524 | 524 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 525 | 525 | $this->Form->append($item); |
| 526 | 526 | } |
@@ -532,11 +532,11 @@ discard block |
||
| 532 | 532 | * @param array $attributes |
| 533 | 533 | * @return $this |
| 534 | 534 | */ |
| 535 | - public function addTime($label,$attributes=[]) |
|
| 535 | + public function addTime($label, $attributes = []) |
|
| 536 | 536 | { |
| 537 | - if($this->Form instanceof form) |
|
| 537 | + if ($this->Form instanceof form) |
|
| 538 | 538 | { |
| 539 | - $item = new Time($label,$attributes); |
|
| 539 | + $item = new Time($label, $attributes); |
|
| 540 | 540 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 541 | 541 | $this->Form->append($item); |
| 542 | 542 | } |
@@ -548,11 +548,11 @@ discard block |
||
| 548 | 548 | * @param array $attributes |
| 549 | 549 | * @return $this |
| 550 | 550 | */ |
| 551 | - public function addUrl($label,$attributes=[]) |
|
| 551 | + public function addUrl($label, $attributes = []) |
|
| 552 | 552 | { |
| 553 | - if($this->Form instanceof form) |
|
| 553 | + if ($this->Form instanceof form) |
|
| 554 | 554 | { |
| 555 | - $item = new Url($label,$attributes); |
|
| 555 | + $item = new Url($label, $attributes); |
|
| 556 | 556 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 557 | 557 | $this->Form->append($item); |
| 558 | 558 | } |
@@ -564,12 +564,12 @@ discard block |
||
| 564 | 564 | * @param array $attributes |
| 565 | 565 | * @return $this |
| 566 | 566 | */ |
| 567 | - public function addVideo($label,$attributes=[]) |
|
| 567 | + public function addVideo($label, $attributes = []) |
|
| 568 | 568 | { |
| 569 | - if($this->Form instanceof form) |
|
| 569 | + if ($this->Form instanceof form) |
|
| 570 | 570 | { |
| 571 | - $item = new Video($label,$attributes); |
|
| 572 | - $this->Form->Attributes()->set('enctype','multipart/form-data'); |
|
| 571 | + $item = new Video($label, $attributes); |
|
| 572 | + $this->Form->Attributes()->set('enctype', 'multipart/form-data'); |
|
| 573 | 573 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 574 | 574 | $this->Form->append($item); |
| 575 | 575 | } |
@@ -580,11 +580,11 @@ discard block |
||
| 580 | 580 | * @param array $attributes |
| 581 | 581 | * @return $this |
| 582 | 582 | */ |
| 583 | - public function addWeek($label,$attributes=[]) |
|
| 583 | + public function addWeek($label, $attributes = []) |
|
| 584 | 584 | { |
| 585 | - if($this->Form instanceof form) |
|
| 585 | + if ($this->Form instanceof form) |
|
| 586 | 586 | { |
| 587 | - $item = new Week($label,$attributes); |
|
| 587 | + $item = new Week($label, $attributes); |
|
| 588 | 588 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 589 | 589 | $this->Form->append($item); |
| 590 | 590 | } |
@@ -596,11 +596,11 @@ discard block |
||
| 596 | 596 | * @param array $attributes |
| 597 | 597 | * @return $this |
| 598 | 598 | */ |
| 599 | - public function addYesNo($label,$attributes=[]) |
|
| 599 | + public function addYesNo($label, $attributes = []) |
|
| 600 | 600 | { |
| 601 | - if($this->Form instanceof form) |
|
| 601 | + if ($this->Form instanceof form) |
|
| 602 | 602 | { |
| 603 | - $item = new YesNo($label,$attributes); |
|
| 603 | + $item = new YesNo($label, $attributes); |
|
| 604 | 604 | $item->Attributes()->set('value', $this->getDefaultValue($item)); |
| 605 | 605 | $this->Form->append($item); |
| 606 | 606 | } |
@@ -610,16 +610,16 @@ discard block |
||
| 610 | 610 | * @param bool $print |
| 611 | 611 | * @return null|string |
| 612 | 612 | */ |
| 613 | - public function Close($print=true) |
|
| 613 | + public function Close($print = true) |
|
| 614 | 614 | { |
| 615 | 615 | $html = null; |
| 616 | 616 | if ($this->Form instanceof form) |
| 617 | 617 | { |
| 618 | - if($this->Fieldset instanceof fieldsetGenerator) |
|
| 618 | + if ($this->Fieldset instanceof fieldsetGenerator) |
|
| 619 | 619 | $this->Form->append($this->Fieldset->Close()); |
| 620 | 620 | $html = $this->Form->RenderHtml(); |
| 621 | 621 | $this->Form = null; |
| 622 | - if($print) |
|
| 622 | + if ($print) |
|
| 623 | 623 | print_r($html); |
| 624 | 624 | } |
| 625 | 625 | return $html; |
@@ -636,11 +636,11 @@ discard block |
||
| 636 | 636 | * @param $default |
| 637 | 637 | * @return mixed |
| 638 | 638 | */ |
| 639 | - private function getDefaultValue(FormElement $element,$default=null) |
|
| 639 | + private function getDefaultValue(FormElement $element, $default = null) |
|
| 640 | 640 | { |
| 641 | 641 | $name = $element->Attributes()->get('name'); |
| 642 | 642 | $method = strtoupper($this->Request->getMethod()); |
| 643 | - switch($method){ |
|
| 643 | + switch ($method) { |
|
| 644 | 644 | case 'POST': |
| 645 | 645 | case 'PUT': |
| 646 | 646 | case 'DELETE': |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | $Request = $this->Request->query; |
| 652 | 652 | break; |
| 653 | 653 | } |
| 654 | - if(!$value = $Request->get($name, $default)) |
|
| 654 | + if (!$value = $Request->get($name, $default)) |
|
| 655 | 655 | $value = $element->Attributes()->get('value', $default); |
| 656 | 656 | return $value; |
| 657 | 657 | } |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | */ |
| 662 | 662 | public function Open($attributes = []) |
| 663 | 663 | { |
| 664 | - if($this->Form instanceof form) |
|
| 664 | + if ($this->Form instanceof form) |
|
| 665 | 665 | $this->Close(); |
| 666 | 666 | $this->Form = new form($attributes); |
| 667 | 667 | return $this; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | use KeyNormalizer; |
| 17 | 17 | |
| 18 | 18 | private $attributes; |
| 19 | - private $ignore ; |
|
| 19 | + private $ignore; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * AttributesBuilder constructor. |
@@ -28,17 +28,17 @@ discard block |
||
| 28 | 28 | { |
| 29 | 29 | $this->attributes = new Collection(); |
| 30 | 30 | $this->ignore = new Collection(); |
| 31 | - if(!empty($attributes)) |
|
| 31 | + if (!empty($attributes)) |
|
| 32 | 32 | { |
| 33 | 33 | is_array($attributes) or $attributes = array($attributes); |
| 34 | - $attributes = array_change_key_case($attributes,CASE_LOWER); |
|
| 35 | - $attributes = $this->array_map_keys([$this,'normalize'],$attributes); |
|
| 34 | + $attributes = array_change_key_case($attributes, CASE_LOWER); |
|
| 35 | + $attributes = $this->array_map_keys([$this, 'normalize'], $attributes); |
|
| 36 | 36 | $this->attributes->add($attributes); |
| 37 | 37 | } |
| 38 | - if(!empty($ignore)) |
|
| 38 | + if (!empty($ignore)) |
|
| 39 | 39 | { |
| 40 | 40 | is_array($ignore) or $ignore = array($ignore); |
| 41 | - $ignore = array_map([$this,'normalize'],$ignore); |
|
| 41 | + $ignore = array_map([$this, 'normalize'], $ignore); |
|
| 42 | 42 | $this->ignore->add($ignore); |
| 43 | 43 | } |
| 44 | 44 | return $this; |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | public function createElementID($key) |
| 52 | 52 | { |
| 53 | 53 | $key = ucfirst($this->normalize($key)); |
| 54 | - if(strpos($key,'input')!==0) |
|
| 54 | + if (strpos($key, 'input') !== 0) |
|
| 55 | 55 | $key = 'input'.$key; |
| 56 | - $this->set('id',$key); |
|
| 56 | + $this->set('id', $key); |
|
| 57 | 57 | return $this; |
| 58 | 58 | } |
| 59 | 59 | |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | { |
| 66 | 66 | $token or $token = microtime(true); |
| 67 | 67 | $token = $this->normalize($token); |
| 68 | - if(strpos($token,'form-')!==0) |
|
| 68 | + if (strpos($token, 'form-') !== 0) |
|
| 69 | 69 | $token = 'form-'.$token; |
| 70 | - $this->set('name',md5($token)); |
|
| 70 | + $this->set('name', md5($token)); |
|
| 71 | 71 | return $this; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public function add(array $attributes) |
| 79 | 79 | { |
| 80 | 80 | is_array($attributes) or $attributes = array($attributes); |
| 81 | - $attributes = $this->array_map_keys([$this,'normalize'],$attributes); |
|
| 81 | + $attributes = $this->array_map_keys([$this, 'normalize'], $attributes); |
|
| 82 | 82 | $this->attributes->add($attributes); |
| 83 | 83 | return $this; |
| 84 | 84 | } |
@@ -88,10 +88,10 @@ discard block |
||
| 88 | 88 | * @param $default |
| 89 | 89 | * @return mixed |
| 90 | 90 | */ |
| 91 | - public function get($key,$default=null) |
|
| 91 | + public function get($key, $default = null) |
|
| 92 | 92 | { |
| 93 | 93 | $key = $this->normalize($key); |
| 94 | - return $this->attributes->get($key,$default); |
|
| 94 | + return $this->attributes->get($key, $default); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | public function Ignore($ignore) |
| 111 | 111 | { |
| 112 | 112 | is_array($ignore) or $ignore = array($ignore); |
| 113 | - $ignore = array_merge($this->ignore->all(), array_map([$this,'normalize'],$ignore)); |
|
| 113 | + $ignore = array_merge($this->ignore->all(), array_map([$this, 'normalize'], $ignore)); |
|
| 114 | 114 | $this->ignore->replace($ignore); |
| 115 | 115 | return $this; |
| 116 | 116 | } |
@@ -131,10 +131,10 @@ discard block |
||
| 131 | 131 | * @param $value |
| 132 | 132 | * @return $this |
| 133 | 133 | */ |
| 134 | - public function set($key,$value) |
|
| 134 | + public function set($key, $value) |
|
| 135 | 135 | { |
| 136 | 136 | $key = $this->normalize($key); |
| 137 | - $this->attributes->set($key,$value); |
|
| 137 | + $this->attributes->set($key, $value); |
|
| 138 | 138 | return $this; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -152,23 +152,23 @@ discard block |
||
| 152 | 152 | public function RenderHtml() |
| 153 | 153 | { |
| 154 | 154 | $output = []; |
| 155 | - if($attributes = $this->attributes->all()) |
|
| 155 | + if ($attributes = $this->attributes->all()) |
|
| 156 | 156 | { |
| 157 | 157 | AttributesMapper::filter($this); |
| 158 | 158 | $filtered = array_keys($attributes); |
| 159 | - if($ignore = $this->ignore->all()) |
|
| 159 | + if ($ignore = $this->ignore->all()) |
|
| 160 | 160 | $filtered = array_diff($filtered, $ignore); |
| 161 | 161 | $attributes = array_intersect_key($attributes, array_flip($filtered)); |
| 162 | - foreach($attributes as $key=>$value) |
|
| 162 | + foreach ($attributes as $key=>$value) |
|
| 163 | 163 | { |
| 164 | - if(is_array($value)): |
|
| 165 | - $output[]= $key.'="'.implode(' ',array_values($value)).'"'; |
|
| 164 | + if (is_array($value)): |
|
| 165 | + $output[] = $key.'="'.implode(' ', array_values($value)).'"'; |
|
| 166 | 166 | else: |
| 167 | - if(is_numeric($key)) $output[]= $value; |
|
| 168 | - else $output[]= $key.'="'.$value.'"'; |
|
| 167 | + if (is_numeric($key)) $output[] = $value; |
|
| 168 | + else $output[] = $key.'="'.$value.'"'; |
|
| 169 | 169 | endif; |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | - return count($output) ? ' ' . implode(' ', $output) : ''; |
|
| 172 | + return count($output) ? ' '.implode(' ', $output) : ''; |
|
| 173 | 173 | } |
| 174 | 174 | } |