DistrictType::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 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
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\City;
8
use App\Entity\District;
9
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
10
use Symfony\Component\Form\AbstractType;
11
use Symfony\Component\Form\FormBuilderInterface;
12
use Symfony\Component\OptionsResolver\OptionsResolver;
13
14
final class DistrictType extends AbstractType
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function buildForm(FormBuilderInterface $builder, array $options): void
20
    {
21
        $builder
22
            ->add('city', EntityType::class, [
23
                'class' => City::class,
24
                'choice_label' => 'name',
25
                'label' => 'city',
26
            ])
27
            ->add('name', null, [
28
                'label' => 'label.district_name',
29
            ])
30
            ->add('slug', null, [
31
                'label' => 'label.slug',
32
            ]);
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function configureOptions(OptionsResolver $resolver): void
39
    {
40
        $resolver->setDefaults([
41
            'data_class' => District::class,
42
        ]);
43
    }
44
}
45