| Conditions | 3 |
| Paths | 2 |
| Total Lines | 34 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 20 | public function editable($value, Field $field, HTMLNode $previous): HTMLNode |
||
| 21 | { |
||
| 22 | /** @var HTMLNode $base */ |
||
| 23 | $base = $this->_editable($value, $field, $previous); |
||
| 24 | $base->addAttribute('class', "control"); |
||
| 25 | |||
| 26 | // add a div.field container |
||
| 27 | $container = HTMLNode::factory( |
||
| 28 | 'div', |
||
| 29 | [ |
||
| 30 | 'class' => "field", |
||
| 31 | 'data-attribute' => $field->getName(), |
||
| 32 | 'data-datatype' => $field->getDatatype()->getName(), |
||
| 33 | 'data-basetype' => $field->getDatatype()->getBasetype() |
||
| 34 | ], |
||
| 35 | $base |
||
| 36 | ); |
||
| 37 | |||
| 38 | // move the main label to the div.field container |
||
| 39 | $label = $base->get('label.formularium-label'); |
||
| 40 | if (!empty($label)) { |
||
| 41 | // delete |
||
| 42 | $base->filter(function ($e) { |
||
| 43 | return !($e->getTag() === 'label' && $e->getAttribute('class') === ['formularium-label']); |
||
| 44 | }); |
||
| 45 | // fix class |
||
| 46 | $label[0]->addAttributes([ |
||
| 47 | 'class' => 'label', |
||
| 48 | ]); |
||
| 49 | // prepend |
||
| 50 | $container->prependContent($label[0]); |
||
| 51 | } |
||
| 52 | |||
| 53 | return $container; |
||
| 54 | } |
||
| 56 |