src/Form/AddressType.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Form;
  3. use App\Entity\Address;
  4. use Symfony\Component\Form\Extension\Core\Type\TextType;
  5. use Symfony\Component\Form\AbstractType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. class AddressType extends AbstractType
  9. {
  10.     public function buildForm(FormBuilderInterface $builder, array $options): void
  11.     {
  12.         $builder
  13.             ->add('street'TextType::class, [
  14.                 'label' => 'Ulice',
  15.                 'required' => true,
  16.                 'attr' => [
  17.                     'readonly' => true,
  18.                 ]
  19.             ])
  20.             ->add('houseNumber'TextType::class, [
  21.                 'label' => 'Číslo popisné',
  22.                 'required' => true,
  23.                 'attr' => [
  24.                     'readonly' => true,
  25.                 ]
  26.             ])
  27.             ->add('city'TextType::class, [
  28.                 'label' => 'Město',
  29.                 'required' => true,
  30.                 'attr' => [
  31.                     'readonly' => true,
  32.                 ]
  33.             ])
  34.             ->add('postcode'TextType::class, [
  35.                 'label' => 'PSČ',
  36.                 'required' => true,
  37.                 'attr' => [
  38.                     'readonly' => true,
  39.                 ]
  40.             ])
  41.             ->add('name'TextType::class, [
  42.                 'label' => 'Jméno',
  43.                 'required' => true,
  44.                 'attr' => [
  45.                     'placeholder' => 'Jméno'
  46.                 ]
  47.             ])
  48.             ->add('surname'TextType::class, [
  49.                 'label' => 'Příjmení',
  50.                 'required' => true,
  51.                 'attr' => [
  52.                     'placeholder' => 'Příjmení'
  53.                 ]
  54.             ])
  55.             ->add('phone'TextType::class, [
  56.                 'label' => 'Telefon',
  57.                 'required' => true,
  58.                 'attr' => [
  59.                     'placeholder' => 'Telefon'
  60.                 ]
  61.             ])
  62.         ;
  63.     }
  64.     public function configureOptions(OptionsResolver $resolver): void
  65.     {
  66.         $resolver->setDefaults([
  67.             'data_class' => Address::class,
  68.         ]);
  69.     }
  70. }