src/Form/UserRegistrationIdentityInfoType.php line 14

  1. <?php
  2. namespace App\Form;
  3. use App\Entity\UserIdentityInfo;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\FileType;
  6. use Symfony\Component\Form\FormBuilderInterface;
  7. use Symfony\Component\OptionsResolver\OptionsResolver;
  8. use Symfony\Component\Validator\Constraints\Length;
  9. use Symfony\Component\Validator\Constraints\Regex;
  10. use Symfony\Contracts\Translation\TranslatorInterface;
  11. class UserRegistrationIdentityInfoType extends AbstractType
  12. {
  13.     /**
  14.      * @var Translator
  15.      */
  16.     protected $translator;
  17.     /**
  18.      * AuctionVehiclesBiddingType constructor.
  19.      * @param Translator|null $translator
  20.      */
  21.     public function __construct(TranslatorInterface $translatornull)
  22.     {
  23.         $this->translator $translator;
  24.     }
  25.     public function buildForm(FormBuilderInterface $builder, array $options)
  26.     {
  27.         $trans $this->translator;
  28.         $nameValidation  $trans->trans('you should add the first name', [], 'validators');
  29.         $idNumValidation $trans->trans('you should add correct identification number', [], 'validators');
  30.         $required_field  $trans->trans('required field', [], 'vehicles');
  31.         $builder->add('firstnameAr'     ,null, array(
  32.             'label'    => 'first name',
  33.             'required' => true,
  34.             'attr'     => [
  35.                 'validate-msg' => $nameValidation,
  36.                 'class'        => 'form-control',
  37.                 'placeholder'  => 'name'
  38.             ]
  39.         ));
  40.         $builder->add('firstnameAr'     ,null, array(
  41.             'label'    => 'first name',
  42.             'required' => true,
  43.             'attr'     => [
  44.                 'validate-msg' => $nameValidation,
  45.                 'class'        => 'form-control',
  46.                 'placeholder'  => 'name'
  47.             ]
  48.         ));
  49.         $builder->add('fourthnameAr',null, array(
  50.             'label'    => 'fourth name',
  51.             'required' => true,
  52.             'attr'     => ['class' => 'form-control margin-bottom-20''validate-msg' => $required_field]
  53.         ));
  54.         $builder->add('identificationNumber',null, array(
  55.             'label'       => 'Identification number',
  56.             'required'    => true,
  57.             'constraints' => array(
  58.                 new Length(array('min' => 10'max' => 10)),
  59.                 new Regex('/^(1|2)\d{9}$/')
  60.             ),
  61.             'attr'        => [
  62.                 'minlength'    => 10,
  63.                 'maxlength'    => 10,
  64.                 'pattern'      => '^(1|2)[0-9]{9}$',
  65.                 'validate-msg' => $idNumValidation,
  66.                 'class'        => 'form-control',
  67.                 'placeholder'  => 'Identification number'
  68.             ]
  69.         ));
  70.     }
  71.     /**
  72.      * {@inheritdoc}
  73.      */
  74.     public function configureOptions(OptionsResolver $resolver)
  75.     {
  76.         $resolver->setDefaults(array(
  77.             'data_class'         => UserIdentityInfo::class,
  78.             'locale'             => 'en',
  79.             'translation_domain' => 'clients'
  80.         ));
  81.     }
  82.     /**
  83.      * {@inheritdoc}
  84.      *
  85.      * @return null|string
  86.      */
  87.     public function getBlockPrefix()
  88.     {
  89.         return 'appbundle_useridentityinfo_registration';
  90.     }
  91. }