File modules/template_engine/components/html/component_inputarea/InputareaComponent.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_inputarea; 4 5 use template_engine\components\html\FieldComponent; 6 use template_engine\element\CMSElement; 7 use template_engine\element\Value; 8 use template_engine\element\ValueExpression; 9 10 class InputareaComponent extends FieldComponent 11 { 12 13 public $rows = 10; 14 15 public $cols = 40; 16 17 public $value; 18 19 public $index; 20 21 public $onchange; 22 23 public $prefix; 24 25 public $class = 'inputarea'; 26 27 public $required = false; 28 29 public $default; 30 31 public $maxlength = 0; 32 33 public $label; 34 35 36 public function createElement() 37 { 38 $textarea = (new CMSElement('textarea')); 39 $textarea->addStyleClass('input'); 40 41 $textarea->addAttribute('name',$this->name); 42 if ( $this->readonly ) 43 $textarea->addAttribute('disabled','disabled'); 44 45 if ( $this->maxlength ) 46 $textarea->addAttribute('maxlength',$this->maxlength); 47 48 if ( $this->required ) 49 $textarea->addAttribute( 'required','required'); 50 51 if ( $this->readonly && $this->required ) { 52 $hidden = (new CMSElement('input'))->addAttribute('type','hidden')->addAttribute('name',$this->name)->addAttribute('value','1'); 53 $textarea->addChild( $hidden ); 54 } 55 56 if ($this->class ) 57 $textarea->addStyleClass($this->class); 58 59 60 61 if (isset($this->default)) 62 $textarea->content($this->default); 63 else 64 $textarea->content(Value::createExpression(ValueExpression::TYPE_DATA_VAR,$this->name)); 65 66 67 if ( $this->label ) { 68 $label = new CMSElement('label'); 69 $label->addStyleClass('form-row')->addStyleClass('form-checkbox'); 70 $label->addChild( (new CMSElement('span'))->addStyleClass('form-label')->content($this->label)); 71 72 $textarea->asChildOf($label); 73 return $label; 74 } 75 76 return $textarea; 77 } 78 }
Download modules/template_engine/components/html/component_inputarea/InputareaComponent.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.