]> Raphaƫl G. Git Repositories - airbundle/blob - Form/RegisterType.php
Add todo
[airbundle] / Form / RegisterType.php
1 <?php
2
3 namespace Rapsys\AirBundle\Form;
4
5 use Symfony\Component\Form\Extension\Core\Type\TelType;
6 use Symfony\Component\Form\Extension\Core\Type\UrlType;
7 use Symfony\Component\Form\FormBuilderInterface;
8 use Symfony\Component\OptionsResolver\OptionsResolver;
9 use Symfony\Component\Validator\Constraints\NotBlank;
10
11 class RegisterType extends \Rapsys\UserBundle\Form\RegisterType {
12 /**
13 * {@inheritdoc}
14 */
15 public function buildForm(FormBuilderInterface $builder, array $options) {
16 //Call parent build form
17 $form = parent::buildForm($builder, $options);
18
19 //Add extra phone field
20 if (!empty($options['phone'])) {
21 $form->add('phone', TelType::class, ['attr' => ['placeholder' => 'Your phone'], 'required' => false]);
22 }
23
24 //Return form
25 return $form;
26 }
27
28 /**
29 * {@inheritdoc}
30 */
31 public function configureOptions(OptionsResolver $resolver) {
32 //Call parent configure options
33 parent::configureOptions($resolver);
34
35 //Set defaults
36 $resolver->setDefaults(['phone' => true]);
37
38 //Add extra mail option
39 $resolver->setAllowedTypes('phone', 'boolean');
40 }
41
42
43 /**
44 * {@inheritdoc}
45 */
46 public function getName() {
47 return 'rapsys_air_register';
48 }
49 }