-
Notifications
You must be signed in to change notification settings - Fork 17
/
SettingsExtensionType.php
55 lines (49 loc) · 1.42 KB
/
SettingsExtensionType.php
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
<?php
/*
* This file is part of Monsieur Biz' Settings plugin for Sylius.
*
* (c) Monsieur Biz <sylius@monsieurbiz.com>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace App\Form;
use MonsieurBiz\SyliusSettingsPlugin\Form\AbstractSettingsExtension;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
class SettingsExtensionType extends AbstractSettingsExtension
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if ($this->isDefaultForm($builder)) {
$this->addWithDefaultCheckbox(
$builder,
'demo_title',
TextType::class,
[
'required' => true,
'constraints' => [
new Assert\NotBlank(),
],
]
);
} else {
$this->addWithDefaultCheckbox(
$builder,
'demo_title',
TextType::class,
[
'required' => false,
]
);
}
}
public static function getExtendedTypes(): array
{
return [
SettingsType::class,
];
}
}