<?php
namespace App\Form;
use App\Entity\UserIdentityInfo;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\Regex;
use Symfony\Contracts\Translation\TranslatorInterface;
class UserRegistrationIdentityInfoType extends AbstractType
{
/**
* @var Translator
*/
protected $translator;
/**
* AuctionVehiclesBiddingType constructor.
* @param Translator|null $translator
*/
public function __construct(TranslatorInterface $translator= null)
{
$this->translator = $translator;
}
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$trans = $this->translator;
$nameValidation = $trans->trans('you should add the first name', [], 'validators');
$idNumValidation = $trans->trans('you should add correct identification number', [], 'validators');
$required_field = $trans->trans('required field', [], 'vehicles');
$builder->add('firstnameAr' ,null, array(
'label' => 'first name',
'required' => true,
'attr' => [
'validate-msg' => $nameValidation,
'class' => 'form-control',
'placeholder' => 'name'
]
));
$builder->add('firstnameAr' ,null, array(
'label' => 'first name',
'required' => true,
'attr' => [
'validate-msg' => $nameValidation,
'class' => 'form-control',
'placeholder' => 'name'
]
));
$builder->add('fourthnameAr',null, array(
'label' => 'fourth name',
'required' => true,
'attr' => ['class' => 'form-control margin-bottom-20', 'validate-msg' => $required_field]
));
$builder->add('identificationNumber',null, array(
'label' => 'Identification number',
'required' => true,
'constraints' => array(
new Length(array('min' => 10, 'max' => 10)),
new Regex('/^(1|2)[0-9]{9}$/')
),
'attr' => [
'minlength' => 10,
'maxlength' => 10,
'pattern' => '^(1|2)[0-9]{9}$',
'validate-msg' => $idNumValidation,
'class' => 'form-control',
'placeholder' => 'Identification number'
]
));
}
/**
* {@inheritdoc}
*
* @param OptionsResolver $resolver
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => UserIdentityInfo::class,
'locale' => 'en',
'translation_domain' => 'clients'
));
}
/**
* {@inheritdoc}
*
* @return null|string
*/
public function getBlockPrefix()
{
return 'appbundle_useridentityinfo_registration';
}
}