src/Form/Backend/Shared/AddressType.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Form\Backend\Shared;
  3. use App\Entity\Address;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilderInterface;
  6. use Symfony\Component\OptionsResolver\OptionsResolver;
  7. class AddressType extends AbstractType
  8. {
  9.     /**
  10.      * @param FormBuilderInterface $builder
  11.      * @param array $options
  12.      *
  13.      * @return void
  14.      */
  15.     public function buildForm(FormBuilderInterface $builder, array $options): void
  16.     {
  17.         $builder
  18.             ->add('company')
  19.             ->add(
  20.                 'street',
  21.                 null,
  22.                 [
  23.                 'required' => true
  24.                 ]
  25.             )
  26.             ->add(
  27.                 'housenr',
  28.                 null,
  29.                 [
  30.                 'required' => true
  31.                 ]
  32.             )
  33.             ->add(
  34.                 'zipcode',
  35.                 null,
  36.                 [
  37.                 'required' => true
  38.                 ]
  39.             )
  40.             ->add(
  41.                 'city',
  42.                 null,
  43.                 [
  44.                 'required' => true
  45.                 ]
  46.             )
  47.             ->add('country');
  48.     }
  49.     public function configureOptions(OptionsResolver $resolver): void
  50.     {
  51.         $resolver->setDefaults(
  52.             [
  53.             'data_class' => Address::class,
  54.             ]
  55.         );
  56.     }
  57. }