Total Complexity | 2 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | final class HiddenInput extends Widget |
||
11 | { |
||
12 | private FormModelInterface $data; |
||
13 | private string $attribute; |
||
14 | private array $options = []; |
||
15 | |||
16 | /** |
||
17 | * Generates a hidden input tag for the given form attribute. |
||
18 | * |
||
19 | * @return string the generated input tag. |
||
20 | */ |
||
21 | 15 | public function run(): string |
|
22 | { |
||
23 | 15 | return Input::widget() |
|
24 | 15 | ->type('hidden') |
|
|
|||
25 | 15 | ->config($this->data, $this->attribute, $this->options) |
|
26 | 15 | ->run(); |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * Set form model, name and options for the widget. |
||
31 | * |
||
32 | * @param FormModelInterface $data Form model. |
||
33 | * @param string $attribute Form model property this widget is rendered for. |
||
34 | * @param array $options The HTML attributes for the widget container tag. |
||
35 | * See {@see \Yiisoft\Html\Html::renderTagAttributes()} for details on how attributes are being rendered. |
||
36 | * |
||
37 | * @return self |
||
38 | */ |
||
39 | 15 | public function config(FormModelInterface $data, string $attribute, array $options = []): self |
|
46 | } |
||
47 | } |
||
48 |