1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys PackBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\AirBundle\Form
;
14 use Symfony\Component\Form\Extension\Core\Type\TextType
;
15 use Symfony\Component\Form\Extension\Core\Type\TelType
;
16 use Symfony\Component\Form\Extension\Core\Type\UrlType
;
17 use Symfony\Component\Form\FormBuilderInterface
;
18 use Symfony\Component\OptionsResolver\OptionsResolver
;
19 use Symfony\Component\Validator\Constraints\NotBlank
;
21 class RegisterType
extends \Rapsys\UserBundle\Form\RegisterType
{
25 public function buildForm(FormBuilderInterface
$builder, array $options): FormBuilderInterface
{
26 //Call parent build form
27 $form = parent
::buildForm($builder, $options);
29 //Add extra donate field
30 if (!empty($options['donate'])) {
31 $form->add('donate', UrlType
::class, ['attr' => ['placeholder' => 'Your donate'], 'required' => false]);
34 //Add extra link field
35 if (!empty($options['link'])) {
36 $form->add('link', UrlType
::class, ['attr' => ['placeholder' => 'Your link'], 'required' => false]);
39 //Add extra phone field
40 if (!empty($options['phone'])) {
41 $form->add('phone', TelType
::class, ['attr' => ['placeholder' => 'Your phone'], 'required' => false]);
44 //Add extra profile field
45 if (!empty($options['profile'])) {
46 $form->add('profile', UrlType
::class, ['attr' => ['placeholder' => 'Your profile'], 'required' => false]);
56 public function configureOptions(OptionsResolver
$resolver): void {
57 //Call parent configure options
58 parent
::configureOptions($resolver);
61 $resolver->setDefaults(['donate' => true, 'link' => true, 'phone' => true, 'profile' => true]);
63 //Add extra donate option
64 $resolver->setAllowedTypes('donate', 'boolean');
66 //Add extra link option
67 $resolver->setAllowedTypes('link', 'boolean');
69 //Add extra phone option
70 $resolver->setAllowedTypes('phone', 'boolean');
72 //Add extra profile option
73 $resolver->setAllowedTypes('profile', 'boolean');
80 public function getName(): string {
81 return 'rapsys_air_register';