Conditions | 7 |
Paths | 7 |
Total Lines | 38 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function create() |
||
24 | { |
||
25 | parent::create(); |
||
26 | |||
27 | $result = []; |
||
28 | |||
29 | foreach ($this->definition['options'] as $optionName => $valueDef) { |
||
30 | |||
31 | $output = '<' . $this->inputType; |
||
32 | |||
33 | $output .= ' value="' . $valueDef['value'] . '"'; |
||
34 | |||
35 | foreach ($this->definition['attributes'] as $attr => $val) { |
||
36 | $output .= ' ' . $attr . '="' . $val . '" '; |
||
37 | } |
||
38 | |||
39 | $output .= ' id="' . $this->definition['attributes']['name'] . '_' . $valueDef['value'] . '"'; |
||
40 | |||
41 | if (!empty($this->getValue()) && $valueDef['value'] === $this->getValue()) { |
||
42 | $output .= ' checked="checked"'; |
||
43 | } elseif (empty($this->getValue()) && $this->definition['default'] === $optionName) { |
||
44 | $output .= ' checked="checked"'; |
||
45 | } |
||
46 | |||
47 | $output .= '/>'; |
||
48 | |||
49 | $result[$optionName] = [ |
||
50 | 'label' => $valueDef['label'], |
||
51 | 'field' => $output |
||
52 | ]; |
||
53 | |||
54 | } |
||
55 | |||
56 | $this->element = $result; |
||
57 | |||
58 | return $this; |
||
59 | |||
60 | } |
||
61 | |||
81 | } |