Conditions | 6 |
Paths | 6 |
Total Lines | 28 |
Code Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
18 | public function editable($value, Field $field, HTMLNode $previous): HTMLNode |
||
19 | { |
||
20 | $validators = $field->getValidators(); |
||
21 | |||
22 | $element = $this->getInput($previous); |
||
23 | if (!$element) { |
||
|
|||
24 | return $previous; |
||
25 | } |
||
26 | |||
27 | $datatype = $field->getDatatype(); |
||
28 | |||
29 | foreach ($validators as $validator => $data) { |
||
30 | switch ($validator) { |
||
31 | case MinLength::class: |
||
32 | $element->setAttribute('minlength', $field->getValidatorOption($validator, 'value', '')); |
||
33 | break; |
||
34 | case MaxLength::class: |
||
35 | $element->setAttribute('maxlength', $field->getValidatorOption($validator, 'value', '')); |
||
36 | break; |
||
37 | case Regex::class: |
||
38 | $element->setAttribute('pattern', $field->getValidatorOption($validator, 'value', '')); |
||
39 | break; |
||
40 | default: |
||
41 | break; |
||
42 | } |
||
43 | } |
||
44 | |||
45 | return $previous; |
||
46 | } |
||
65 |