@@ -10,57 +10,57 @@ discard block |
||
10 | 10 | * @author jc |
11 | 11 | * @version 1.001 |
12 | 12 | */ |
13 | -class HtmlForm extends HtmlSemCollection{ |
|
13 | +class HtmlForm extends HtmlSemCollection { |
|
14 | 14 | |
15 | 15 | use FieldsTrait; |
16 | 16 | |
17 | 17 | protected $_fields; |
18 | 18 | |
19 | - public function __construct( $identifier, $elements=array()){ |
|
20 | - parent::__construct( $identifier, "form", "ui form"); |
|
19 | + public function __construct($identifier, $elements=array()) { |
|
20 | + parent::__construct($identifier, "form", "ui form"); |
|
21 | 21 | $this->setProperty("name", $this->identifier); |
22 | 22 | $this->_fields=array(); |
23 | 23 | $this->addItems($elements); |
24 | 24 | } |
25 | 25 | |
26 | - public function addHeader($title,$niveau=1,$dividing=true){ |
|
27 | - $header=new HtmlHeader("",$niveau,$title); |
|
28 | - if($dividing) |
|
26 | + public function addHeader($title, $niveau=1, $dividing=true) { |
|
27 | + $header=new HtmlHeader("", $niveau, $title); |
|
28 | + if ($dividing) |
|
29 | 29 | $header->setDividing(); |
30 | 30 | return $this->addItem($header); |
31 | 31 | } |
32 | 32 | |
33 | - public function addFields($fields,$label=NULL){ |
|
34 | - if(!$fields instanceof HtmlFormFields){ |
|
35 | - if(\is_array($fields)===false){ |
|
36 | - $fields = \func_get_args(); |
|
33 | + public function addFields($fields, $label=NULL) { |
|
34 | + if (!$fields instanceof HtmlFormFields) { |
|
35 | + if (\is_array($fields)===false) { |
|
36 | + $fields=\func_get_args(); |
|
37 | 37 | $end=\end($fields); |
38 | - if(\is_string($end)){ |
|
38 | + if (\is_string($end)) { |
|
39 | 39 | $label=$end; |
40 | 40 | \array_pop($fields); |
41 | 41 | }else $label=NULL; |
42 | 42 | } |
43 | - $this->_fields=\array_merge($this->_fields,$fields); |
|
44 | - $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(),$fields); |
|
43 | + $this->_fields=\array_merge($this->_fields, $fields); |
|
44 | + $fields=new HtmlFormFields("fields-".$this->identifier."-".$this->count(), $fields); |
|
45 | 45 | } |
46 | - if(isset($label)) |
|
47 | - $fields=new HtmlFormField("", $fields,$label); |
|
46 | + if (isset($label)) |
|
47 | + $fields=new HtmlFormField("", $fields, $label); |
|
48 | 48 | $this->addItem($fields); |
49 | 49 | return $fields; |
50 | 50 | } |
51 | 51 | |
52 | - public function addItem($item){ |
|
52 | + public function addItem($item) { |
|
53 | 53 | $item=parent::addItem($item); |
54 | - if(\is_subclass_of($item, HtmlFormField::class)===true){ |
|
54 | + if (\is_subclass_of($item, HtmlFormField::class)===true) { |
|
55 | 55 | $this->_fields[]=$item; |
56 | 56 | } |
57 | 57 | return $item; |
58 | 58 | } |
59 | 59 | |
60 | - public function getField($index){ |
|
61 | - if(\is_string($index)){ |
|
60 | + public function getField($index) { |
|
61 | + if (\is_string($index)) { |
|
62 | 62 | $field=$this->getElementById($index, $this->_fields); |
63 | - }else{ |
|
63 | + }else { |
|
64 | 64 | $field=$this->_fields[$index]; |
65 | 65 | } |
66 | 66 | return $field; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * automatically divide fields to be equal width |
71 | 71 | * @return \Ajax\semantic\html\collections\form\HtmlForm |
72 | 72 | */ |
73 | - public function setEqualWidth(){ |
|
73 | + public function setEqualWidth() { |
|
74 | 74 | return $this->addToProperty("class", "equal width"); |
75 | 75 | } |
76 | 76 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param HtmlFormField $field |
80 | 80 | * @return \Ajax\common\html\HtmlDoubleElement |
81 | 81 | */ |
82 | - public function addField($field){ |
|
82 | + public function addField($field) { |
|
83 | 83 | return $this->addItem($field); |
84 | 84 | } |
85 | 85 | } |
86 | 86 | \ No newline at end of file |
@@ -3,11 +3,11 @@ |
||
3 | 3 | namespace Ajax\semantic\html\collections\form; |
4 | 4 | |
5 | 5 | trait TextFieldsTrait { |
6 | - public function setPlaceholder($value){ |
|
6 | + public function setPlaceholder($value) { |
|
7 | 7 | return $this->getField()->setPlaceholder($value); |
8 | 8 | } |
9 | 9 | |
10 | - public function setValue($value){ |
|
10 | + public function setValue($value) { |
|
11 | 11 | return $this->getField()->setValue($value); |
12 | 12 | } |
13 | 13 | } |
14 | 14 | \ No newline at end of file |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | protected $_equalWidth; |
15 | 15 | protected $_name; |
16 | 16 | |
17 | - public function __construct($identifier, $fields=array(),$equalWidth=true) { |
|
17 | + public function __construct($identifier, $fields=array(), $equalWidth=true) { |
|
18 | 18 | parent::__construct($identifier, "div"); |
19 | 19 | $this->_equalWidth=$equalWidth; |
20 | 20 | $this->addItems($fields); |
@@ -24,35 +24,35 @@ discard block |
||
24 | 24 | * @param string|HtmlSemDoubleElement $label |
25 | 25 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
26 | 26 | */ |
27 | - public function setLabel($label){ |
|
27 | + public function setLabel($label) { |
|
28 | 28 | $labelO=$label; |
29 | - if(\is_string($label)){ |
|
30 | - $labelO=new HtmlSemDoubleElement("","label","",$label); |
|
29 | + if (\is_string($label)) { |
|
30 | + $labelO=new HtmlSemDoubleElement("", "label", "", $label); |
|
31 | 31 | } |
32 | - $this->insertItem($labelO,0); |
|
32 | + $this->insertItem($labelO, 0); |
|
33 | 33 | return $labelO; |
34 | 34 | } |
35 | 35 | |
36 | - public function compile(JsUtils $js=NULL,View $view=NULL){ |
|
37 | - if($this->_equalWidth){ |
|
36 | + public function compile(JsUtils $js=NULL, View $view=NULL) { |
|
37 | + if ($this->_equalWidth) { |
|
38 | 38 | $count=$this->count(); |
39 | 39 | $this->addToProperty("class", Wide::getConstants()["W".$count]." fields"); |
40 | 40 | }else |
41 | - $this->addToProperty("class","fields"); |
|
42 | - return parent::compile($js,$view); |
|
41 | + $this->addToProperty("class", "fields"); |
|
42 | + return parent::compile($js, $view); |
|
43 | 43 | } |
44 | 44 | |
45 | - public function setWidth($index,$width){ |
|
45 | + public function setWidth($index, $width) { |
|
46 | 46 | $this->_equalWidth=false; |
47 | 47 | return $this->getItem($index)->setWidth($width); |
48 | 48 | } |
49 | 49 | |
50 | - public function setInline(){ |
|
50 | + public function setInline() { |
|
51 | 51 | $this->_equalWidth=false; |
52 | 52 | $this->addToProperty("class", "inline"); |
53 | 53 | } |
54 | 54 | |
55 | - public function setGrouped(){ |
|
55 | + public function setGrouped() { |
|
56 | 56 | $this->_equalWidth=false; |
57 | 57 | $this->addToProperty("class", "grouped"); |
58 | 58 | } |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
69 | - public static function radios($name,$items=array(),$label=NULL){ |
|
69 | + public static function radios($name, $items=array(), $label=NULL) { |
|
70 | 70 | $fields=array(); |
71 | 71 | $i=0; |
72 | - foreach ($items as $item){ |
|
73 | - $fields[]=new HtmlFormRadio($name."-".$i++,$name,$item,$item); |
|
72 | + foreach ($items as $item) { |
|
73 | + $fields[]=new HtmlFormRadio($name."-".$i++, $name, $item, $item); |
|
74 | 74 | } |
75 | - $radios=new HtmlFormFields("fields-".$name,$fields); |
|
76 | - if(isset($label)) |
|
75 | + $radios=new HtmlFormFields("fields-".$name, $fields); |
|
76 | + if (isset($label)) |
|
77 | 77 | $radios->setLabel($label)->setProperty("for", $name); |
78 | 78 | return $radios; |
79 | 79 | } |