| @@ -153,15 +153,20 @@ | ||
| 153 | 153 | |
| 154 | 154 | public static function checkbutton($field_name, $field_value, $field_label, $attributes=[]) | 
| 155 | 155 |    { | 
| 156 | - if(!isset($attributes['id'])) | |
| 157 | - $attributes['id']=$field_name; | |
| 156 | +    if(!isset($attributes['id'])) { | |
| 157 | + $attributes['id']=$field_name; | |
| 158 | + } | |
| 158 | 159 | |
| 159 | - if(!isset($attributes['type'])) | |
| 160 | - $attributes['type']='checkbox'; // default | |
| 160 | +    if(!isset($attributes['type'])) { | |
| 161 | + $attributes['type']='checkbox'; | |
| 162 | + } | |
| 163 | + // default | |
| 161 | 164 | |
| 162 | - if(isset($attributes['is_checked']) && $attributes['is_checked'] === true) // for boolean checkbuttons | |
| 165 | +    if(isset($attributes['is_checked']) && $attributes['is_checked'] === true) { | |
| 166 | + // for boolean checkbuttons | |
| 163 | 167 |      { | 
| 164 | 168 | $attributes['checked'] = 'checked'; | 
| 169 | + } | |
| 165 | 170 | unset($attributes['is_checked']); | 
| 166 | 171 | } | 
| 167 | 172 | |
| @@ -38,10 +38,11 @@ discard block | ||
| 38 | 38 | public static function input($field_name, $field_value=null, $attributes=[], $errors=[]) | 
| 39 | 39 |    { | 
| 40 | 40 | |
| 41 | -    if(isset($attributes['disabled']) || !isset($attributes['type']) || in_array('disabled', $attributes, true)) | |
| 42 | - $attributes['type'] = 'text'; | |
| 43 | - else | |
| 44 | - $attributes['type'] = $attributes['type'] ?? 'text'; | |
| 41 | +    if(isset($attributes['disabled']) || !isset($attributes['type']) || in_array('disabled', $attributes, true)) { | |
| 42 | + $attributes['type'] = 'text'; | |
| 43 | +    } else { | |
| 44 | + $attributes['type'] = $attributes['type'] ?? 'text'; | |
| 45 | + } | |
| 45 | 46 | |
| 46 | 47 | $attributes['name'] = $attributes['name'] ?? $field_name; | 
| 47 | 48 | $attributes['value'] = $attributes['value'] ?? $field_value; | 
| @@ -63,8 +64,9 @@ discard block | ||
| 63 | 64 | foreach($option_list as $value => $label) | 
| 64 | 65 |      { | 
| 65 | 66 | $option_attributes = ['value' => $value]; | 
| 66 | - if($selected == $value) | |
| 67 | - $option_attributes['selected'] = 'selected'; | |
| 67 | +      if($selected == $value) { | |
| 68 | + $option_attributes['selected'] = 'selected'; | |
| 69 | + } | |
| 68 | 70 | |
| 69 | 71 |        $options .= new Element('option', $label, $option_attributes); | 
| 70 | 72 | } | 
| @@ -87,9 +89,9 @@ discard block | ||
| 87 | 89 | $attributes['id'] = $attributes['id'] ?? $field_id; | 
| 88 | 90 | unset($attributes['name']); | 
| 89 | 91 | $attributes['type'] = 'submit'; | 
| 90 | - if(isset($attributes['tag']) && $attributes['tag'] === 'input') | |
| 91 | -      return new Element('input', '', $attributes); | |
| 92 | - else | |
| 92 | +    if(isset($attributes['tag']) && $attributes['tag'] === 'input') { | |
| 93 | +          return new Element('input', '', $attributes); | |
| 94 | + } else | |
| 93 | 95 |      { | 
| 94 | 96 | unset($attributes['tag']); | 
| 95 | 97 | unset($attributes['value']); | 
| @@ -27,9 +27,10 @@ discard block | ||
| 27 | 27 |    { | 
| 28 | 28 | $ret = ''; | 
| 29 | 29 | |
| 30 | - foreach($this->attributeList as $k => $v) | |
| 31 | - if(!is_null($v) && $v !== '' && !is_array($v)) | |
| 30 | +    foreach($this->attributeList as $k => $v) { | |
| 31 | + if(!is_null($v) && $v !== '' && !is_array($v)) | |
| 32 | 32 |          $ret .=  is_int($k) ? " $v" : sprintf(' %s="%s"', $k, $v); | 
| 33 | + } | |
| 33 | 34 | |
| 34 | 35 | return $ret; | 
| 35 | 36 | } | 
| @@ -39,9 +40,9 @@ discard block | ||
| 39 | 40 | $flattributes = $this->format_attributes(); | 
| 40 | 41 | |
| 41 | 42 | $ret = ''; | 
| 42 | - if($this->is_void()) | |
| 43 | -      $ret = sprintf('<%s%s/>', $this->tagName, $flattributes); | |
| 44 | - else | |
| 43 | +    if($this->is_void()) { | |
| 44 | +          $ret = sprintf('<%s%s/>', $this->tagName, $flattributes); | |
| 45 | + } else | |
| 45 | 46 |      { | 
| 46 | 47 |        $ret = sprintf('<%s%s>%s</%s>', | 
| 47 | 48 | $this->tagName, |