Passed
Branch master (539d05)
by Alfred
02:00
created
Elements/Date.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@
 block discarded – undo
13 13
     public function __construct($label, $attributes)
14 14
     {
15 15
         parent::__construct($label, $attributes);
16
-        $this->Attributes()->set('type','date');
17
-        $this->Attributes()->set('title','YYYY-dd-MM (e.g. ' . date('Y-m-d') . ')');
16
+        $this->Attributes()->set('type', 'date');
17
+        $this->Attributes()->set('title', 'YYYY-dd-MM (e.g. '.date('Y-m-d').')');
18 18
     }
19 19
 
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
Elements/Password.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
11 11
 
12 12
 class Password extends Text
13 13
 {
14
-    public function __construct($label, $attributes=[])
14
+    public function __construct($label, $attributes = [])
15 15
     {
16 16
         parent::__construct($label, $attributes);
17
-        $this->Attributes()->set('type','password');
18
-        $this->Attributes()->set('minlength','6');
19
-        $this->Attributes()->set('maxlength','64');
20
-        $this->Attributes()->set('required','required');
21
-        $this->Attributes()->set('placeholder','**********');
17
+        $this->Attributes()->set('type', 'password');
18
+        $this->Attributes()->set('minlength', '6');
19
+        $this->Attributes()->set('maxlength', '64');
20
+        $this->Attributes()->set('required', 'required');
21
+        $this->Attributes()->set('placeholder', '**********');
22 22
     }
23 23
 
24 24
 }
25 25
\ No newline at end of file
Please login to merge, or discard this patch.
Elements/Checkbox.php 2 patches
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
      * @param array $options
23 23
      * @param array $attributes
24 24
      */
25
-    public function __construct($label, array $options, array $attributes=[])
25
+    public function __construct($label, array $options, array $attributes = [])
26 26
     {
27 27
         parent::__construct($label, $attributes);
28 28
         $this->options = $options;
29
-        $this->Attributes()->set('type','checkbox');
29
+        $this->Attributes()->set('type', 'checkbox');
30 30
     }
31 31
 
32 32
     /**
@@ -35,40 +35,40 @@  discard block
 block discarded – undo
35 35
     public function RenderHtml()
36 36
     {
37 37
         $html = '';
38
-        if($this->Types()->has($this->Attributes()->get('type')))
38
+        if ($this->Types()->has($this->Attributes()->get('type')))
39 39
         {
40
-            if(!$this->Attributes()->has('id'))
41
-                $this->Attributes()->createElementID($this->Attributes()->get('name',$this->label()->getItemID()));
42
-            $this->label()->Attribute()->set('fieldtype',$this->Attributes()->get('type'));
43
-            $this->label()->Attribute()->set('for',$this->Attributes()->get('id'));
44
-            if(sizeof($this->options)<2)
40
+            if (!$this->Attributes()->has('id'))
41
+                $this->Attributes()->createElementID($this->Attributes()->get('name', $this->label()->getItemID()));
42
+            $this->label()->Attribute()->set('fieldtype', $this->Attributes()->get('type'));
43
+            $this->label()->Attribute()->set('for', $this->Attributes()->get('id'));
44
+            if (sizeof($this->options) < 2)
45 45
             {
46
-                if($this->Attributes()->get('value'))
47
-                    $this->Attributes()->set('checked','checked');
48
-                $this->Attributes()->set('value','1');
49
-                $this->hiddenInput = new Hidden($this->Label(),['value'=>'0']);
46
+                if ($this->Attributes()->get('value'))
47
+                    $this->Attributes()->set('checked', 'checked');
48
+                $this->Attributes()->set('value', '1');
49
+                $this->hiddenInput = new Hidden($this->Label(), ['value'=>'0']);
50 50
             }
51
-            if($this->hiddenInput instanceof FormElementInterface)
51
+            if ($this->hiddenInput instanceof FormElementInterface)
52 52
                 return  parent::RenderHtml().$this->hiddenInput->RenderHtml();
53
-            if($this->Attributes()->has('value'))
53
+            if ($this->Attributes()->has('value'))
54 54
             {
55
-                if(!is_array($this->Attributes()->get('value')))
56
-                    $this->Attributes()->set('value',[$this->Attributes()->get('value')]);
55
+                if (!is_array($this->Attributes()->get('value')))
56
+                    $this->Attributes()->set('value', [$this->Attributes()->get('value')]);
57 57
             }
58 58
             else
59
-                $this->Attributes()->set('value',[]);
60
-            if(substr($this->Attributes()->get('name'), -2) !== '[]')
61
-                $this->Attributes()->set('name',$this->Attributes()->get('name').'[]');
59
+                $this->Attributes()->set('value', []);
60
+            if (substr($this->Attributes()->get('name'), -2) !== '[]')
61
+                $this->Attributes()->set('name', $this->Attributes()->get('name').'[]');
62 62
             $count = 0;
63 63
             $html .= $this->Label()->RenderHtml();
64 64
             $this->Attributes()->Ignore(['id', 'value', 'checked', 'required']);
65
-            foreach($this->options as $index => $details)
65
+            foreach ($this->options as $index => $details)
66 66
             {
67 67
                 $html .= '<label for="'.$this->Attributes()->get('id').'-'.$count.'">';
68 68
                 $html .= '<input id="'.$this->Attributes()->get('id').'-'.$count.'"';
69 69
                 $html .= ' value="'.$index.'"';
70 70
                 $html .= $this->Attributes()->RenderHtml();
71
-                if(in_array($index , $this->Attributes()->get('value'))) $html .= ' checked="checked"';
71
+                if (in_array($index, $this->Attributes()->get('value'))) $html .= ' checked="checked"';
72 72
                 $html .= ' >'.$details.'</label>';
73 73
                 ++$count;
74 74
             }
Please login to merge, or discard this patch.
Braces   +20 added lines, -13 removed lines patch added patch discarded remove patch
@@ -37,28 +37,33 @@  discard block
 block discarded – undo
37 37
         $html = '';
38 38
         if($this->Types()->has($this->Attributes()->get('type')))
39 39
         {
40
-            if(!$this->Attributes()->has('id'))
41
-                $this->Attributes()->createElementID($this->Attributes()->get('name',$this->label()->getItemID()));
40
+            if(!$this->Attributes()->has('id')) {
41
+                            $this->Attributes()->createElementID($this->Attributes()->get('name',$this->label()->getItemID()));
42
+            }
42 43
             $this->label()->Attribute()->set('fieldtype',$this->Attributes()->get('type'));
43 44
             $this->label()->Attribute()->set('for',$this->Attributes()->get('id'));
44 45
             if(sizeof($this->options)<2)
45 46
             {
46
-                if($this->Attributes()->get('value'))
47
-                    $this->Attributes()->set('checked','checked');
47
+                if($this->Attributes()->get('value')) {
48
+                                    $this->Attributes()->set('checked','checked');
49
+                }
48 50
                 $this->Attributes()->set('value','1');
49 51
                 $this->hiddenInput = new Hidden($this->Label(),['value'=>'0']);
50 52
             }
51
-            if($this->hiddenInput instanceof FormElementInterface)
52
-                return  parent::RenderHtml().$this->hiddenInput->RenderHtml();
53
+            if($this->hiddenInput instanceof FormElementInterface) {
54
+                            return  parent::RenderHtml().$this->hiddenInput->RenderHtml();
55
+            }
53 56
             if($this->Attributes()->has('value'))
54 57
             {
55
-                if(!is_array($this->Attributes()->get('value')))
56
-                    $this->Attributes()->set('value',[$this->Attributes()->get('value')]);
58
+                if(!is_array($this->Attributes()->get('value'))) {
59
+                                    $this->Attributes()->set('value',[$this->Attributes()->get('value')]);
60
+                }
61
+            } else {
62
+                            $this->Attributes()->set('value',[]);
63
+            }
64
+            if(substr($this->Attributes()->get('name'), -2) !== '[]') {
65
+                            $this->Attributes()->set('name',$this->Attributes()->get('name').'[]');
57 66
             }
58
-            else
59
-                $this->Attributes()->set('value',[]);
60
-            if(substr($this->Attributes()->get('name'), -2) !== '[]')
61
-                $this->Attributes()->set('name',$this->Attributes()->get('name').'[]');
62 67
             $count = 0;
63 68
             $html .= $this->Label()->RenderHtml();
64 69
             $this->Attributes()->Ignore(['id', 'value', 'checked', 'required']);
@@ -68,7 +73,9 @@  discard block
 block discarded – undo
68 73
                 $html .= '<input id="'.$this->Attributes()->get('id').'-'.$count.'"';
69 74
                 $html .= ' value="'.$index.'"';
70 75
                 $html .= $this->Attributes()->RenderHtml();
71
-                if(in_array($index , $this->Attributes()->get('value'))) $html .= ' checked="checked"';
76
+                if(in_array($index , $this->Attributes()->get('value'))) {
77
+                  $html .= ' checked="checked"';
78
+                }
72 79
                 $html .= ' >'.$details.'</label>';
73 80
                 ++$count;
74 81
             }
Please login to merge, or discard this patch.
Elements/Number.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,16 +17,16 @@
 block discarded – undo
17 17
     {
18 18
         parent::__construct($label, $attributes);
19 19
 
20
-        $this->attributes->set('type','number');
20
+        $this->attributes->set('type', 'number');
21 21
 
22
-        if(!$this->attributes->has('min'))
23
-            $this->attributes->set('min','0');
22
+        if (!$this->attributes->has('min'))
23
+            $this->attributes->set('min', '0');
24 24
 
25
-        if(!$this->attributes->has('max'))
26
-            $this->attributes->set('max','100');
25
+        if (!$this->attributes->has('max'))
26
+            $this->attributes->set('max', '100');
27 27
 
28
-        if(!$this->attributes->has('step'))
29
-            $this->attributes->set('step','1');
28
+        if (!$this->attributes->has('step'))
29
+            $this->attributes->set('step', '1');
30 30
     }
31 31
 
32 32
 }
33 33
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,14 +19,17 @@
 block discarded – undo
19 19
 
20 20
         $this->attributes->set('type','number');
21 21
 
22
-        if(!$this->attributes->has('min'))
23
-            $this->attributes->set('min','0');
22
+        if(!$this->attributes->has('min')) {
23
+                    $this->attributes->set('min','0');
24
+        }
24 25
 
25
-        if(!$this->attributes->has('max'))
26
-            $this->attributes->set('max','100');
26
+        if(!$this->attributes->has('max')) {
27
+                    $this->attributes->set('max','100');
28
+        }
27 29
 
28
-        if(!$this->attributes->has('step'))
29
-            $this->attributes->set('step','1');
30
+        if(!$this->attributes->has('step')) {
31
+                    $this->attributes->set('step','1');
32
+        }
30 33
     }
31 34
 
32 35
 }
33 36
\ No newline at end of file
Please login to merge, or discard this patch.
Elements/Search.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@
 block discarded – undo
14 14
     public function __construct($label, $attributes)
15 15
     {
16 16
         parent::__construct($label, $attributes);
17
-        $this->Attributes()->set('type','search');
18
-        $this->Attributes()->set('required','required');
17
+        $this->Attributes()->set('type', 'search');
18
+        $this->Attributes()->set('required', 'required');
19 19
     }
20 20
 
21 21
 }
22 22
\ No newline at end of file
Please login to merge, or discard this patch.
Elements/Captcha.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,40 +11,40 @@
 block discarded – undo
11 11
 
12 12
 class Captcha extends Text
13 13
 {
14
-    public function __construct($label='Security Code', $attributes)
14
+    public function __construct($label = 'Security Code', $attributes)
15 15
     {
16
-        $operators = ['+','x','-'];
17
-        $operator = $operators[rand(0,2)];
18
-        switch($operator):
16
+        $operators = ['+', 'x', '-'];
17
+        $operator = $operators[rand(0, 2)];
18
+        switch ($operator):
19 19
             case 'x':
20
-                do{
21
-                    $firstnumber = rand(3,7);
22
-                    $secondnumber = rand(2,6);
20
+                do {
21
+                    $firstnumber = rand(3, 7);
22
+                    $secondnumber = rand(2, 6);
23 23
                     $response = $firstnumber * $secondnumber;
24
-                } while($response > 35);
24
+                } while ($response > 35);
25 25
                 break;
26 26
             case '-':
27
-                do{
28
-                    $firstnumber = rand(6,11);
29
-                    $secondnumber = rand(1,8);
27
+                do {
28
+                    $firstnumber = rand(6, 11);
29
+                    $secondnumber = rand(1, 8);
30 30
                     $response = $firstnumber - $secondnumber;
31
-                } while($response < 2);
31
+                } while ($response < 2);
32 32
                 break;
33 33
             default:
34
-                $firstnumber = rand(3,8);
35
-                $secondnumber = rand(1,7);
34
+                $firstnumber = rand(3, 8);
35
+                $secondnumber = rand(1, 7);
36 36
                 $response = $firstnumber + $secondnumber;
37 37
                 break;
38 38
         endswitch;
39 39
         $label .= ". $firstnumber $operator $secondnumber";
40 40
         parent::__construct($label, $attributes);
41
-        $this->Attributes()->set('name', str_replace(". $firstnumber $operator $secondnumber",'',$label));
41
+        $this->Attributes()->set('name', str_replace(". $firstnumber $operator $secondnumber", '', $label));
42 42
         $this->Attributes()->createElementID($this->Attributes()->get('name'));
43
-        $this->Attributes()->set('maxlength',2);
44
-        $this->Attributes()->set('required','required');
45
-        $this->Attributes()->set('pattern','[0-9]{1,2}');
46
-        $this->Attributes()->set('placeholder','Enter result');
47
-        $this->Attributes()->set('capresponse',$response);
43
+        $this->Attributes()->set('maxlength', 2);
44
+        $this->Attributes()->set('required', 'required');
45
+        $this->Attributes()->set('pattern', '[0-9]{1,2}');
46
+        $this->Attributes()->set('placeholder', 'Enter result');
47
+        $this->Attributes()->set('capresponse', $response);
48 48
       /*  $this->Attributes()->set('capfirstnumber',$firstnumber);
49 49
         $this->Attributes()->set('capsecondnumber',$secondnumber);
50 50
         $this->Attributes()->set('capoperator',$operator);*/
Please login to merge, or discard this patch.
Elements/Button.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@
 block discarded – undo
12 12
 
13 13
 class Button extends Text
14 14
 {
15
-    public function __construct($label, $attributes=[])
15
+    public function __construct($label, $attributes = [])
16 16
     {
17 17
         parent::__construct($label, $attributes);
18 18
 
19
-        $this->Attributes()->set('type','button');
20
-        $this->Attributes()->set('value',(!$label instanceof LabelGenerator)? $label : $label->getItem());
19
+        $this->Attributes()->set('type', 'button');
20
+        $this->Attributes()->set('value', (!$label instanceof LabelGenerator) ? $label : $label->getItem());
21 21
     }
22 22
 
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
Elements/Hidden.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
     public function __construct($label, $attributes)
15 15
     {
16 16
         parent::__construct($label, $attributes);
17
-        $this->Attributes()->set('type','hidden');
17
+        $this->Attributes()->set('type', 'hidden');
18 18
     }
19 19
 
20 20
 }
21 21
\ No newline at end of file
Please login to merge, or discard this patch.
Elements/Select.php 2 patches
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
      * @param array $options
22 22
      * @param array $attributes
23 23
      */
24
-    public function __construct($label, array $options, array $attributes =[])
24
+    public function __construct($label, array $options, array $attributes = [])
25 25
     {
26 26
         parent::__construct($label, $options, $attributes);
27
-        $this->Attributes()->set('type','select');
28
-        $this->Attributes()->set('placeholder',$this->Attributes()->get('placeholder','Make a choise ...'));
27
+        $this->Attributes()->set('type', 'select');
28
+        $this->Attributes()->set('placeholder', $this->Attributes()->get('placeholder', 'Make a choise ...'));
29 29
         $this->Attributes()->Ignore('select');
30 30
     }
31 31
     /**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     {
36 36
 
37 37
         $html = '';
38
-        $multiple=false;
38
+        $multiple = false;
39 39
 
40 40
         if (!$this->Attributes()->has('id'))
41 41
             $this->Attributes()->createElementID($this->Attributes()->get('name', $this->label()->getItemID()));
@@ -43,50 +43,50 @@  discard block
 block discarded – undo
43 43
         $this->label()->Attribute()->set('for', $this->Attributes()->get('id'));
44 44
 
45 45
 
46
-        if($this->Attributes()->has('value'))
46
+        if ($this->Attributes()->has('value'))
47 47
         {
48
-            if(!is_array($this->Attributes()->get('value')))
49
-                $this->Attributes()->set('value',[$this->Attributes()->get('value')]);
48
+            if (!is_array($this->Attributes()->get('value')))
49
+                $this->Attributes()->set('value', [$this->Attributes()->get('value')]);
50 50
         }
51 51
         else
52
-            $this->Attributes()->set('value',[]);
52
+            $this->Attributes()->set('value', []);
53 53
 
54
-        if($this->Attributes()->has('multiple') AND $this->Attributes()->get('multiple')==='multiple')
55
-            $multiple=true;
54
+        if ($this->Attributes()->has('multiple') AND $this->Attributes()->get('multiple') === 'multiple')
55
+            $multiple = true;
56 56
 
57
-        if($multiple)
58
-        {   $this->Attributes()->set('size',$this->Attributes()->get('size',3));
59
-            if(substr($this->Attributes()->get('name'), -2) !== '[]')
60
-                $this->Attributes()->set('name',$this->Attributes()->get('name').'[]');
57
+        if ($multiple)
58
+        {   $this->Attributes()->set('size', $this->Attributes()->get('size', 3));
59
+            if (substr($this->Attributes()->get('name'), -2) !== '[]')
60
+                $this->Attributes()->set('name', $this->Attributes()->get('name').'[]');
61 61
         }
62 62
         $html .= $this->Label()->RenderHtml();
63
-        $this->Attributes()->Ignore(['value','selected','optgroup-attributes','option-attributes','placeholder']);
63
+        $this->Attributes()->Ignore(['value', 'selected', 'optgroup-attributes', 'option-attributes', 'placeholder']);
64 64
 
65 65
         $html .= '<select'.$this->Attributes()->RenderHtml().'>';
66
-        if(empty($this->Attributes()->get('value')[0]) and $this->Attributes()->has('placeholder'))
66
+        if (empty($this->Attributes()->get('value')[0]) and $this->Attributes()->has('placeholder'))
67 67
             $html .= '<option value="" disabled selected>'.$this->Attributes()->get('placeholder').'</option>';
68 68
 
69
-        foreach($this->options as $index=>$datas):
69
+        foreach ($this->options as $index=>$datas):
70 70
 
71
-            if(is_array($datas))
72
-                $html .= $this->createOptgroup($index,$datas);
71
+            if (is_array($datas))
72
+                $html .= $this->createOptgroup($index, $datas);
73 73
             else
74 74
             {
75 75
                 $optionAttr = null;
76
-                if($this->Attributes()->has('option-attributes'))
76
+                if ($this->Attributes()->has('option-attributes'))
77 77
                 {
78 78
                     $oOption = new AttributesBuilder($this->Attributes()->get('option-attributes'));
79
-                    $oOption->Ignore(['value','selected','placeholder']);
80
-                    $oOption->set('type','option');
79
+                    $oOption->Ignore(['value', 'selected', 'placeholder']);
80
+                    $oOption->set('type', 'option');
81 81
                     $optionAttr .= $oOption->RenderHtml();
82 82
                 }
83 83
                 $html .= '<option value="'.$index.'"';
84
-                if(!$this->selected and in_array($index,$this->Attributes()->get('value')))
84
+                if (!$this->selected and in_array($index, $this->Attributes()->get('value')))
85 85
                 {
86 86
                     $html .= ' selected="selected"';
87 87
                     $this->selected = true;
88 88
                 }
89
-                if($optionAttr) $html .= ' '.$optionAttr ;
89
+                if ($optionAttr) $html .= ' '.$optionAttr;
90 90
                 $html .= '>';
91 91
                 $html .= $datas.'</option>';
92 92
             }
@@ -100,45 +100,45 @@  discard block
 block discarded – undo
100 100
      * @param array $options
101 101
      * @return string
102 102
      */
103
-    private function createOptgroup($label,$options = [])
103
+    private function createOptgroup($label, $options = [])
104 104
     {
105 105
         $groupAttr = null;
106 106
         $optionAttr = null;
107
-        if($this->Attributes()->has('optgroup-attributes'))
107
+        if ($this->Attributes()->has('optgroup-attributes'))
108 108
         {
109 109
             $oGroup = new AttributesBuilder($this->Attributes()->get('optgroup-attributes'));
110
-            $oGroup->set('type','optgroup');
110
+            $oGroup->set('type', 'optgroup');
111 111
             $oGroup->Ignore('label');
112 112
             $groupAttr .= $oGroup->RenderHtml();
113 113
         }
114
-        if($this->Attributes()->has('option-attributes'))
114
+        if ($this->Attributes()->has('option-attributes'))
115 115
         {
116 116
             $oOption = new AttributesBuilder($this->Attributes()->get('option-attributes'));
117
-            $oOption->Ignore(['value','selected','placeholder']);
118
-            $oOption->set('type','option');
117
+            $oOption->Ignore(['value', 'selected', 'placeholder']);
118
+            $oOption->set('type', 'option');
119 119
             $optionAttr .= $oOption->RenderHtml();
120 120
         }
121
-        $output='<optgroup label="'.$label.'"';
122
-        if($groupAttr) $output .= ' '.$groupAttr ;
121
+        $output = '<optgroup label="'.$label.'"';
122
+        if ($groupAttr) $output .= ' '.$groupAttr;
123 123
         $output .= '>';
124
-        foreach($options as $key=>$optLabel)
124
+        foreach ($options as $key=>$optLabel)
125 125
         {
126
-            if(is_array($optLabel))
127
-                $output .= call_user_func_array([$this,__METHOD__],[$optLabel]);
126
+            if (is_array($optLabel))
127
+                $output .= call_user_func_array([$this, __METHOD__], [$optLabel]);
128 128
             else
129 129
             {
130 130
                 $output .= '<option value="'.$key.'"';
131
-                if(!$this->selected and in_array($key,$this->Attributes()->get('value')))
131
+                if (!$this->selected and in_array($key, $this->Attributes()->get('value')))
132 132
                 {
133 133
                     $output .= ' selected="selected"';
134 134
                     $this->selected = true;
135 135
                 }
136
-                if($optionAttr) $output .= ' '.$optionAttr ;
136
+                if ($optionAttr) $output .= ' '.$optionAttr;
137 137
                 $output .= '>';
138 138
                 $output .= $optLabel.'</option>';
139 139
             }
140 140
         }
141
-        $output.='</optgroup>';
141
+        $output .= '</optgroup>';
142 142
         return$output;
143 143
         
144 144
     }
Please login to merge, or discard this patch.
Braces   +32 added lines, -21 removed lines patch added patch discarded remove patch
@@ -37,40 +37,45 @@  discard block
 block discarded – undo
37 37
         $html = '';
38 38
         $multiple=false;
39 39
 
40
-        if (!$this->Attributes()->has('id'))
41
-            $this->Attributes()->createElementID($this->Attributes()->get('name', $this->label()->getItemID()));
40
+        if (!$this->Attributes()->has('id')) {
41
+                    $this->Attributes()->createElementID($this->Attributes()->get('name', $this->label()->getItemID()));
42
+        }
42 43
         $this->label()->Attribute()->set('fieldtype', $this->Attributes()->get('type'));
43 44
         $this->label()->Attribute()->set('for', $this->Attributes()->get('id'));
44 45
 
45 46
 
46 47
         if($this->Attributes()->has('value'))
47 48
         {
48
-            if(!is_array($this->Attributes()->get('value')))
49
-                $this->Attributes()->set('value',[$this->Attributes()->get('value')]);
49
+            if(!is_array($this->Attributes()->get('value'))) {
50
+                            $this->Attributes()->set('value',[$this->Attributes()->get('value')]);
51
+            }
52
+        } else {
53
+                    $this->Attributes()->set('value',[]);
50 54
         }
51
-        else
52
-            $this->Attributes()->set('value',[]);
53 55
 
54
-        if($this->Attributes()->has('multiple') AND $this->Attributes()->get('multiple')==='multiple')
55
-            $multiple=true;
56
+        if($this->Attributes()->has('multiple') AND $this->Attributes()->get('multiple')==='multiple') {
57
+                    $multiple=true;
58
+        }
56 59
 
57 60
         if($multiple)
58 61
         {   $this->Attributes()->set('size',$this->Attributes()->get('size',3));
59
-            if(substr($this->Attributes()->get('name'), -2) !== '[]')
60
-                $this->Attributes()->set('name',$this->Attributes()->get('name').'[]');
62
+            if(substr($this->Attributes()->get('name'), -2) !== '[]') {
63
+                            $this->Attributes()->set('name',$this->Attributes()->get('name').'[]');
64
+            }
61 65
         }
62 66
         $html .= $this->Label()->RenderHtml();
63 67
         $this->Attributes()->Ignore(['value','selected','optgroup-attributes','option-attributes','placeholder']);
64 68
 
65 69
         $html .= '<select'.$this->Attributes()->RenderHtml().'>';
66
-        if(empty($this->Attributes()->get('value')[0]) and $this->Attributes()->has('placeholder'))
67
-            $html .= '<option value="" disabled selected>'.$this->Attributes()->get('placeholder').'</option>';
70
+        if(empty($this->Attributes()->get('value')[0]) and $this->Attributes()->has('placeholder')) {
71
+                    $html .= '<option value="" disabled selected>'.$this->Attributes()->get('placeholder').'</option>';
72
+        }
68 73
 
69 74
         foreach($this->options as $index=>$datas):
70 75
 
71
-            if(is_array($datas))
72
-                $html .= $this->createOptgroup($index,$datas);
73
-            else
76
+            if(is_array($datas)) {
77
+                            $html .= $this->createOptgroup($index,$datas);
78
+            } else
74 79
             {
75 80
                 $optionAttr = null;
76 81
                 if($this->Attributes()->has('option-attributes'))
@@ -86,7 +91,9 @@  discard block
 block discarded – undo
86 91
                     $html .= ' selected="selected"';
87 92
                     $this->selected = true;
88 93
                 }
89
-                if($optionAttr) $html .= ' '.$optionAttr ;
94
+                if($optionAttr) {
95
+                  $html .= ' '.$optionAttr ;
96
+                }
90 97
                 $html .= '>';
91 98
                 $html .= $datas.'</option>';
92 99
             }
@@ -119,13 +126,15 @@  discard block
 block discarded – undo
119 126
             $optionAttr .= $oOption->RenderHtml();
120 127
         }
121 128
         $output='<optgroup label="'.$label.'"';
122
-        if($groupAttr) $output .= ' '.$groupAttr ;
129
+        if($groupAttr) {
130
+          $output .= ' '.$groupAttr ;
131
+        }
123 132
         $output .= '>';
124 133
         foreach($options as $key=>$optLabel)
125 134
         {
126
-            if(is_array($optLabel))
127
-                $output .= call_user_func_array([$this,__METHOD__],[$optLabel]);
128
-            else
135
+            if(is_array($optLabel)) {
136
+                            $output .= call_user_func_array([$this,__METHOD__],[$optLabel]);
137
+            } else
129 138
             {
130 139
                 $output .= '<option value="'.$key.'"';
131 140
                 if(!$this->selected and in_array($key,$this->Attributes()->get('value')))
@@ -133,7 +142,9 @@  discard block
 block discarded – undo
133 142
                     $output .= ' selected="selected"';
134 143
                     $this->selected = true;
135 144
                 }
136
-                if($optionAttr) $output .= ' '.$optionAttr ;
145
+                if($optionAttr) {
146
+                  $output .= ' '.$optionAttr ;
147
+                }
137 148
                 $output .= '>';
138 149
                 $output .= $optLabel.'</option>';
139 150
             }
Please login to merge, or discard this patch.