コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('value', TextType::class, ['constraints' => [new Callback(function ($value, ExecutionContextInterface $context) {
         if (!preg_match("/^" . $this->config->getFormat('phone') . "\$/u", $value)) {
             $context->buildViolation($this->translator->trans('phone_number_has_not_valid_format'))->addViolation();
         }
     })], 'invalid_message' => $this->translator->trans('phone_number_has_not_valid_format')]);
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('value', PasswordType::class, ['constraints' => [new Length(['min' => (int) $this->config->getFormat('passwordLength'), 'minMessage' => $this->translator->trans('password_is_too_short')]), new NotBlank()], 'invalid_message' => $this->translator->trans('password_is_too_short')]);
 }
コード例 #3
0
 /**
  * {@inheritDoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('value', RepeatedType::class, ['first_name' => 'password', 'second_name' => 'confirm', 'constraints' => [new Length(['min' => (int) $this->config->getFormat('passwordLength'), 'minMessage' => $this->translator->trans('password_is_too_short')]), new NotBlank()], 'invalid_message' => $this->translator->trans('passwords_are_different')]);
 }