| Total Complexity | 11 |
| Total Lines | 55 |
| Duplicated Lines | 0 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 7 | class Select extends FormElement |
||
| 8 | { |
||
| 9 | /** @var array */ |
||
| 10 | public $options = []; |
||
| 11 | |||
| 12 | /** @var bool */ |
||
| 13 | public $multiple = false; |
||
| 14 | |||
| 15 | /** @var string */ |
||
| 16 | public $nulloption; |
||
| 17 | |||
| 18 | /** @var array */ |
||
| 19 | public $selected = []; |
||
| 20 | |||
| 21 | protected function attributesList() |
||
| 25 | ]; |
||
| 26 | } |
||
| 27 | |||
| 28 | protected function setSpecificAttributes() |
||
| 29 | { |
||
| 30 | $this->setOptions(); |
||
| 31 | $this->setNulloption(); |
||
| 32 | } |
||
| 33 | |||
| 34 | protected function setOptions() |
||
| 35 | { |
||
| 36 | if (isset($this->params['options']) && ! empty($this->params['options'])) { |
||
| 37 | $this->options = $this->params['options']; |
||
| 38 | |||
| 39 | foreach ($this->options as $value => $label) { |
||
| 40 | if (is_array($this->value)) { |
||
| 41 | if (in_array($value, $this->value)) { |
||
| 42 | $this->selected[] = $value; |
||
| 43 | } |
||
| 44 | } else { |
||
| 45 | if ($value == $this->value) { |
||
| 46 | $this->selected[] = $value; |
||
| 47 | } |
||
| 48 | } |
||
| 49 | } |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | protected function setNulloption() |
||
| 56 | } |
||
| 57 | |||
| 58 | protected function setStyles() |
||
| 64 |