-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLabelledChoiceInputTrait.php
More file actions
63 lines (55 loc) · 1.58 KB
/
LabelledChoiceInputTrait.php
File metadata and controls
63 lines (55 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace Ibexa\DesignSystemTwig\Twig\Components;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\UX\TwigComponent\Attribute\ExposeInTemplate;
trait LabelledChoiceInputTrait
{
public string $id;
#[ExposeInTemplate('input_wrapper_class')]
public string $inputWrapperClassName;
#[ExposeInTemplate('label_class')]
public string $labelClassName;
protected function validateLabelledProps(OptionsResolver $resolver): void
{
$resolver
->define('id')
->required()
->allowedTypes('string');
$resolver
->define('inputWrapperClassName')
->allowedTypes('string')
->default('');
$resolver
->define('labelClassName')
->allowedTypes('string')
->default('');
}
/**
* @return array{
* id: string,
* name: string,
* disabled: bool,
* error: bool,
* required: bool,
* value: ?string
* }
*/
#[ExposeInTemplate('input')]
public function getInput(): array
{
return [
'id' => $this->id,
'name' => $this->name,
'checked' => $this->checked,
'disabled' => $this->disabled,
'error' => $this->error,
'required' => $this->required,
'value' => $this->value,
];
}
}