File modules/template_engine/components/html/component_radiobox/RadioboxComponent.class.php

Last commit: Wed Oct 14 22:36:29 2020 +0200	Jan Dankert	Refactoring: Fixed the namespace in component classes, now the are able to be load by the standard autoloader.
1 <?php 2 3 namespace template_engine\components\html\component_radiobox; 4 5 use template_engine\components\html\Component; 6 use template_engine\element\CMSElement; 7 use template_engine\element\PHPBlockElement; 8 use template_engine\element\Value; 9 use template_engine\element\ValueExpression; 10 11 class RadioboxComponent extends Component 12 { 13 14 public $list; 15 16 public $name; 17 18 public $default; 19 20 /** 21 * @deprecated 22 */ 23 public $onchange; 24 25 public $title; 26 27 public $class; 28 29 30 public function createElement() 31 { 32 $radiobox = new PHPBlockElement(); 33 34 $radiobox->beforeBlock = 'foreach( $'.$this->list.' as $_key=>$_value)'; 35 36 if ( $this->default ) 37 $value = $this->default; 38 else 39 $value = '$'.$this->name; 40 41 $label = (new CMSElement('label'))->asChildOf( $radiobox ); 42 43 (new CMSElement('input')) 44 ->addAttribute('type','radio')->addAttribute('name',$this->name) 45 ->addAttribute('value',Value::createExpression(ValueExpression::TYPE_DATA_VAR,'_key')) 46 ->addConditionalAttribute('checked','$_key=='.$value,'checked') 47 ->asChildOf($label); 48 49 (new CMSElement('span')) 50 ->content( Value::createExpression(ValueExpression::TYPE_DATA_VAR,'_value')) 51 ->asChildOf( $label ); 52 (new CMSElement('br')) 53 ->asChildOf( $radiobox ); 54 55 return $radiobox; 56 } 57 }
Download modules/template_engine/components/html/component_radiobox/RadioboxComponent.class.php
History Wed, 14 Oct 2020 22:36:29 +0200 Jan Dankert Refactoring: Fixed the namespace in component classes, now the are able to be load by the standard autoloader. Wed, 14 Oct 2020 22:20:22 +0200 Jan Dankert Refactoring: Renamed component folders, because 'if' is no valid namespace fragment.