openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

HiddenComponent.class.php (659B)


      1 <?php
      2 
      3 namespace template_engine\components\html\component_hidden;
      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 HiddenComponent extends FieldComponent
     11 {
     12 	public $default;
     13 
     14 	public function createElement()
     15 	{
     16 		$input = (new CMSElement('input'))->addAttribute('type','hidden');
     17 		$input->addAttribute('name',$this->name);
     18 
     19 		if ($this->default)
     20 			$input->addAttribute('value',$this->default);
     21 		else
     22 			$input->addAttribute('value',Value::createExpression(ValueExpression::TYPE_DATA_VAR,$this->name));
     23 
     24 		return $input;
     25 	}
     26 }