Conditions | 7 |
Paths | 12 |
Total Lines | 30 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 56 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function renderOptions($options = false) |
||
19 | { |
||
20 | $options = $options ? $options : $this->getElement()->getOptions(); |
||
21 | $return = ''; |
||
22 | |||
23 | $selectedValue = $this->getElement()->getValue(); |
||
24 | |||
25 | foreach ($options as $value=>$atribs) { |
||
26 | if (is_string($value) && !isset($atribs['label'])) { |
||
27 | $return .= '<optgroup label="' . $value . '">'; |
||
28 | $return .= $this->renderOptions($atribs); |
||
29 | $return .= '</optgroup>'; |
||
30 | } else { |
||
31 | $return .= '<option'; |
||
32 | |||
33 | $label = $atribs['label']; |
||
34 | unset($atribs['label']); |
||
35 | |||
36 | $atribs['value'] = $value; |
||
37 | if ($this->isOptionSelected($value, $selectedValue)) { |
||
38 | $atribs['selected'] = 'selected'; |
||
39 | } |
||
40 | |||
41 | foreach ($atribs as $name=>$value) { |
||
|
|||
42 | $return .= ' ' . $name . '="' . $value . '"'; |
||
43 | } |
||
44 | $return .= '>' . $label . '</option>'; |
||
45 | } |
||
46 | } |
||
47 | return $return; |
||
48 | } |
||
70 |