Total Complexity | 6 |
Total Lines | 30 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
10 | class MultiSelectRender extends AbstractFieldRender |
||
11 | { |
||
12 | 5 | public function renderBlock(FieldInterface $field, DOMElement $element): DOMElement |
|
13 | { |
||
14 | 5 | if (!$field instanceof MultiSelect) { |
|
15 | 1 | throw new InvalidArgumentException('Must be a Del\Form\Field\MultiSelect'); |
|
16 | } |
||
17 | |||
18 | 4 | $element->setAttribute('name', $field->getName() . '[]'); |
|
19 | |||
20 | 4 | foreach ($field->getOptions() as $value => $label) { |
|
21 | 3 | $option = $this->processOption($field, $value, $label); |
|
22 | 3 | $element->appendChild($option); |
|
23 | } |
||
24 | |||
25 | 4 | return $element; |
|
26 | } |
||
27 | |||
28 | 3 | private function processOption(FieldInterface $field, $value, $label): DOMElement |
|
40 | } |
||
41 | } |
||
42 |