PropertyDescriptionType::configureOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Form\Type;
6
7
use App\Entity\PropertyDescription;
8
use Symfony\Component\Form\AbstractType;
9
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
10
use Symfony\Component\Form\FormBuilderInterface;
11
use Symfony\Component\OptionsResolver\OptionsResolver;
12
use Symfony\Component\Validator\Constraints\NotNull;
13
14
final class PropertyDescriptionType extends AbstractType
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function buildForm(FormBuilderInterface $builder, array $options): void
20
    {
21
        $builder
22
            ->add('title', null, [
23
                'label' => 'label.title',
24
                'attr' => [
25
                    'required' => true,
26
                ],
27
                'label_attr' => [
28
                    'class' => 'required',
29
                ],
30
                'constraints' => [
31
                    new NotNull(),
32
                ],
33
            ])
34
            ->add('meta_title', null, [
35
                'label' => 'label.meta_title',
36
            ])
37
            ->add('meta_description', null, [
38
                'label' => 'label.meta_description',
39
            ])
40
            ->add('content', TextareaType::class, [
41
                'attr' => [
42
                    'class' => 'form-control summer-note',
43
                    'rows' => '7',
44
                    'required' => true,
45
                ],
46
                'label' => 'label.content',
47
                'constraints' => [
48
                    new NotNull(),
49
                ],
50
            ]);
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function configureOptions(OptionsResolver $resolver): void
57
    {
58
        $resolver->setDefaults([
59
            'data_class' => PropertyDescription::class,
60
        ]);
61
    }
62
}
63