Passed
Push — master ( 858380...1fb59e )
by Jean-Christophe
01:48
created
Ajax/semantic/html/collections/form/HtmlForm.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class HtmlForm extends HtmlSemCollection {
25 25
 
26
-	use FieldsTrait,FormTrait;
26
+	use FieldsTrait, FormTrait;
27 27
 	/**
28 28
 	 * @var array
29 29
 	 */
@@ -38,15 +38,15 @@  discard block
 block discarded – undo
38 38
 
39 39
 	public function __construct($identifier, $elements=array()) {
40 40
 		parent::__construct($identifier, "form", "ui form");
41
-		$this->_states=[ State::ERROR,State::SUCCESS,State::WARNING,State::DISABLED ];
41
+		$this->_states=[State::ERROR, State::SUCCESS, State::WARNING, State::DISABLED];
42 42
 		$this->setProperty("name", $this->identifier);
43
-		$this->_fields=array ();
43
+		$this->_fields=array();
44 44
 		$this->addItems($elements);
45 45
 		$this->_validationParams=[];
46 46
 		$this->_extraFieldRules=[];
47 47
 	}
48 48
 
49
-	protected function getForm(){
49
+	protected function getForm() {
50 50
 		return $this;
51 51
 	}
52 52
 
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	 * @param string $caption
69 69
 	 * @return HtmlForm
70 70
 	 */
71
-	public function addDivider($caption=NULL){
72
-		return $this->addContent(new HtmlDivider("",$caption));
71
+	public function addDivider($caption=NULL) {
72
+		return $this->addContent(new HtmlDivider("", $caption));
73 73
 	}
74 74
 
75 75
 	/**
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
 						$label=NULL;
92 92
 				}
93 93
 				$this->_fields=\array_merge($this->_fields, $fields);
94
-				$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields);
94
+				$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields);
95 95
 			}
96
-			if (isset($label)){
97
-				$fields->wrap("<div class='field'><label>{$label}</label>","</div>");
96
+			if (isset($label)) {
97
+				$fields->wrap("<div class='field'><label>{$label}</label>", "</div>");
98 98
 			}
99 99
 		} else {
100
-			$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count());
100
+			$fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count());
101 101
 		}
102 102
 		$this->addItem($fields);
103 103
 		return $fields;
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
 	public function addItem($item) {
107 107
 		$item=parent::addItem($item);
108
-		if (\is_subclass_of($item, HtmlFormField::class) === true) {
108
+		if (\is_subclass_of($item, HtmlFormField::class)===true) {
109 109
 			$this->_fields[]=$item;
110 110
 		}
111 111
 		return $item;
@@ -163,49 +163,49 @@  discard block
 block discarded – undo
163 163
 
164 164
 
165 165
 
166
-	public function compile(JsUtils $js=NULL,&$view=NULL){
167
-		if(\sizeof($this->_validationParams)>0)
166
+	public function compile(JsUtils $js=NULL, &$view=NULL) {
167
+		if (\sizeof($this->_validationParams)>0)
168 168
 			$this->setProperty("novalidate", "");
169
-		return parent::compile($js,$view);
169
+		return parent::compile($js, $view);
170 170
 	}
171 171
 
172 172
 	public function run(JsUtils $js) {
173
-		if(isset($js)){
173
+		if (isset($js)) {
174 174
 			$compo=$js->semantic()->form("#".$this->identifier);
175
-		}else{
175
+		} else {
176 176
 			$compo=new Form();
177 177
 			$compo->attach("#".$this->identifier);
178 178
 		}
179
-		foreach ($this->_fields as $field){
180
-			if($field instanceof HtmlFormField){
179
+		foreach ($this->_fields as $field) {
180
+			if ($field instanceof HtmlFormField) {
181 181
 				$this->addCompoValidation($compo, $field);
182 182
 			}
183 183
 		}
184
-		foreach ($this->content as $field){
185
-			if($field instanceof HtmlFormFields){
184
+		foreach ($this->content as $field) {
185
+			if ($field instanceof HtmlFormFields) {
186 186
 				$items=$field->getItems();
187
-				foreach ($items as $_field){
188
-					if($_field instanceof HtmlFormField)
187
+				foreach ($items as $_field) {
188
+					if ($_field instanceof HtmlFormField)
189 189
 						$this->addCompoValidation($compo, $_field);
190 190
 				}
191 191
 			}
192 192
 		}
193
-		foreach ($this->_extraFieldRules as $field=>$fieldValidation){
193
+		foreach ($this->_extraFieldRules as $field=>$fieldValidation) {
194 194
 			$this->addExtraCompoValidation($compo, $fieldValidation);
195 195
 		}
196
-		$this->_runValidationParams($compo,$js);
196
+		$this->_runValidationParams($compo, $js);
197 197
 		return $this->_bsComponent;
198 198
 	}
199 199
 	
200
-	public function getExtraFieldValidation($fieldname){
201
-		if(!isset($this->_extraFieldRules[$fieldname])){
200
+	public function getExtraFieldValidation($fieldname) {
201
+		if (!isset($this->_extraFieldRules[$fieldname])) {
202 202
 			$this->_extraFieldRules[$fieldname]=new FieldValidation($fieldname);
203 203
 		}
204 204
 		return $this->_extraFieldRules[$fieldname];
205 205
 	}
206 206
 
207
-	public function addValidationParam($paramName,$paramValue,$before="",$after=""){
208
-		$this->addBehavior($this->_validationParams, $paramName, $paramValue,$before,$after);
207
+	public function addValidationParam($paramName, $paramValue, $before="", $after="") {
208
+		$this->addBehavior($this->_validationParams, $paramName, $paramValue, $before, $after);
209 209
 		return $this;
210 210
 	}
211 211
 
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		return $this;
215 215
 	}
216 216
 	
217
-	public function hasValidationParams(){
217
+	public function hasValidationParams() {
218 218
 		return sizeof($this->_validationParams)>0;
219 219
 	}
220 220
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		return $this->_validationParams;
223 223
 	}
224 224
 
225
-	public function removeValidationParam($param){
225
+	public function removeValidationParam($param) {
226 226
 		unset($this->_validationParams[$param]);
227 227
 		return $this;
228 228
 	}
Please login to merge, or discard this patch.