@@ -12,34 +12,34 @@ discard block |
||
| 12 | 12 | class HtmlFormField extends HtmlSemDoubleElement { |
| 13 | 13 | protected $_container; |
| 14 | 14 | protected $_validation; |
| 15 | - public function __construct($identifier, $field,$label=NULL) { |
|
| 16 | - parent::__construct($identifier, "div","field"); |
|
| 15 | + public function __construct($identifier, $field, $label=NULL) { |
|
| 16 | + parent::__construct($identifier, "div", "field"); |
|
| 17 | 17 | $this->content=array(); |
| 18 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
| 19 | - if(isset($label)) |
|
| 18 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
| 19 | + if (isset($label)) |
|
| 20 | 20 | $this->setLabel($label); |
| 21 | 21 | $this->setField($field); |
| 22 | 22 | $this->_validation=NULL; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
| 26 | - $labelO=new HtmlLabel("",$label); |
|
| 25 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
| 26 | + $labelO=new HtmlLabel("", $label); |
|
| 27 | 27 | $labelO->setPointing($pointing); |
| 28 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
| 28 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
| 29 | 29 | return $labelO; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public function setLabel($label){ |
|
| 32 | + public function setLabel($label) { |
|
| 33 | 33 | $labelO=$label; |
| 34 | - if(\is_string($label)){ |
|
| 35 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
| 34 | + if (\is_string($label)) { |
|
| 35 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
| 36 | 36 | $labelO->setContent($label); |
| 37 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
| 37 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
| 38 | 38 | } |
| 39 | 39 | $this->content["label"]=$labelO; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function setField($field){ |
|
| 42 | + public function setField($field) { |
|
| 43 | 43 | $this->content["field"]=$field; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -47,8 +47,8 @@ discard block |
||
| 47 | 47 | * Returns the label or null |
| 48 | 48 | * @return mixed |
| 49 | 49 | */ |
| 50 | - public function getLabel(){ |
|
| 51 | - if(\array_key_exists("label", $this->content)) |
|
| 50 | + public function getLabel() { |
|
| 51 | + if (\array_key_exists("label", $this->content)) |
|
| 52 | 52 | return $this->content["label"]; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * Return the field |
| 57 | 57 | * @return mixed |
| 58 | 58 | */ |
| 59 | - public function getField(){ |
|
| 59 | + public function getField() { |
|
| 60 | 60 | return $this->content["field"]; |
| 61 | 61 | } |
| 62 | 62 | |
@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | * Return the field with data |
| 65 | 65 | * @return mixed |
| 66 | 66 | */ |
| 67 | - public function getDataField(){ |
|
| 67 | + public function getDataField() { |
|
| 68 | 68 | return $this->content["field"]; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * puts the label before or behind |
| 73 | 73 | */ |
| 74 | - public function swapLabel(){ |
|
| 74 | + public function swapLabel() { |
|
| 75 | 75 | $label=$this->getLabel(); |
| 76 | 76 | unset($this->content["label"]); |
| 77 | 77 | $this->content["label"]=$label; |
@@ -82,31 +82,31 @@ discard block |
||
| 82 | 82 | * @param int $width |
| 83 | 83 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
| 84 | 84 | */ |
| 85 | - public function setWidth($width){ |
|
| 86 | - if(\is_int($width)){ |
|
| 85 | + public function setWidth($width) { |
|
| 86 | + if (\is_int($width)) { |
|
| 87 | 87 | $width=Wide::getConstants()["W".$width]; |
| 88 | 88 | } |
| 89 | 89 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
| 90 | - if(isset($this->_container)){ |
|
| 90 | + if (isset($this->_container)) { |
|
| 91 | 91 | $this->_container->setEqualWidth(false); |
| 92 | 92 | } |
| 93 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
| 93 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * Field displays an error state |
| 98 | 98 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
| 99 | 99 | */ |
| 100 | - public function setError(){ |
|
| 100 | + public function setError() { |
|
| 101 | 101 | return $this->addToProperty("class", "error"); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - public function setInline(){ |
|
| 104 | + public function setInline() { |
|
| 105 | 105 | return $this->addToProperty("class", "inline"); |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function jsState($state){ |
|
| 109 | - return $this->jsDoJquery("addClass",$state); |
|
| 108 | + public function jsState($state) { |
|
| 109 | + return $this->jsDoJquery("addClass", $state); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | public function setContainer($_container) { |
@@ -114,23 +114,23 @@ discard block |
||
| 114 | 114 | return $this; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function setReadonly(){ |
|
| 117 | + public function setReadonly() { |
|
| 118 | 118 | $this->getField()->setProperty("readonly", ""); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
| 121 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
| 122 | 122 | $field=$this->getDataField(); |
| 123 | - if(isset($field)){ |
|
| 124 | - if(!isset($this->_validation)){ |
|
| 123 | + if (isset($field)) { |
|
| 124 | + if (!isset($this->_validation)) { |
|
| 125 | 125 | $this->_validation=new FieldValidation($field->getIdentifier()); |
| 126 | 126 | } |
| 127 | - $this->_validation->addRule($type,$prompt,$value); |
|
| 127 | + $this->_validation->addRule($type, $prompt, $value); |
|
| 128 | 128 | } |
| 129 | 129 | return $this; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - public function addRules(array $rules){ |
|
| 133 | - foreach ($rules as $rule){ |
|
| 132 | + public function addRules(array $rules) { |
|
| 133 | + foreach ($rules as $rule) { |
|
| 134 | 134 | $this->addRule($rule); |
| 135 | 135 | } |
| 136 | 136 | return $this; |
@@ -9,17 +9,17 @@ |
||
| 9 | 9 | class HtmlFormTextarea extends HtmlFormField { |
| 10 | 10 | use TextFieldsTrait; |
| 11 | 11 | |
| 12 | - public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
| 13 | - if(!isset($placeholder)) |
|
| 12 | + public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
| 13 | + if (!isset($placeholder)) |
|
| 14 | 14 | $placeholder=$label; |
| 15 | - parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
|
| 15 | + parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Defines the textarea row count |
| 20 | 20 | * @param int $count |
| 21 | 21 | */ |
| 22 | - public function setRows($count){ |
|
| 22 | + public function setRows($count) { |
|
| 23 | 23 | $this->getField()->setRows($count); |
| 24 | 24 | } |
| 25 | 25 | |
@@ -7,17 +7,17 @@ |
||
| 7 | 7 | use Ajax\semantic\html\elements\HtmlInput; |
| 8 | 8 | |
| 9 | 9 | class HtmlFormInput extends HtmlFormField { |
| 10 | - use TextFieldsTrait,FieldTrait; |
|
| 10 | + use TextFieldsTrait, FieldTrait; |
|
| 11 | 11 | |
| 12 | - public function __construct($identifier, $label=NULL,$type="text",$value=NULL,$placeholder=NULL) { |
|
| 13 | - if(!isset($placeholder) && $type==="text") |
|
| 12 | + public function __construct($identifier, $label=NULL, $type="text", $value=NULL, $placeholder=NULL) { |
|
| 13 | + if (!isset($placeholder) && $type==="text") |
|
| 14 | 14 | $placeholder=$label; |
| 15 | - parent::__construct("field-".$identifier, new HtmlInput($identifier,$type,$value,$placeholder), $label); |
|
| 15 | + parent::__construct("field-".$identifier, new HtmlInput($identifier, $type, $value, $placeholder), $label); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function getDataField(){ |
|
| 19 | - $field= $this->getField(); |
|
| 20 | - if($field instanceof HtmlInput) |
|
| 18 | + public function getDataField() { |
|
| 19 | + $field=$this->getField(); |
|
| 20 | + if ($field instanceof HtmlInput) |
|
| 21 | 21 | $field=$field->getField(); |
| 22 | 22 | return $field; |
| 23 | 23 | } |