~ucl-cs-study-devs/study.cs.ucl-websites/password-cn

« back to all changes in this revision

Viewing changes to src/UCL/StudyBundle/Form/Type/RegistrationType.php

  • Committer: Steve DODIER-LAZARO
  • Date: 2015-06-21 23:56:23 UTC
  • Revision ID: sdodierl@secdev.cs.ucl.ac.uk-20150621235623-bd8awkjopup2lml1
Adding a city of origin screening criteria, and removing the multitasking ones

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 
9
9
class RegistrationType extends AbstractType
10
10
{
11
 
    /* You MUST define email and browser in the options -- See DefaultController's use of this class */
12
11
    public function buildForm(FormBuilderInterface $builder, array $options)
13
12
    {
14
13
      $builder->add('pseudonym', 'text', array(
25
24
          'required' => true,
26
25
      ));
27
26
      
28
 
      $builder->add('proficiency', 'choice', array(
29
 
          'label'      => 'form.reg.proficiency.label',
30
 
          'choices'   => array(
31
 
              'beginner'   => 'form.reg.proficiency.beginner',
32
 
              'poweruser' => 'form.reg.proficiency.advanced',
33
 
              'techy'   => 'form.reg.proficiency.tech',
34
 
              'pro'   => 'form.reg.proficiency.pro',
35
 
          ),
36
 
          'multiple'  => false,
37
 
          'required'  => true,
38
 
          'expanded'  => true,
39
 
      ));
40
 
      
41
27
      $builder->add('occupation', 'text', array(
42
28
          'label' => 'form.reg.occupation',
43
29
          'required'  => true,
57
43
          'expanded'  => true,
58
44
      ));
59
45
      
60
 
      $builder->add('distro', 'choice', array(
61
 
          'label' => 'form.reg.distro.label',
62
 
          'choices'   => array(
63
 
              //'debian'   => 'Debian',
64
 
              'ubuntu' => 'form.reg.distro.ubuntu',
65
 
              'other'   => 'form.reg.distro.other',
66
 
          ),
67
 
          'multiple'  => false,
68
 
          'required'  => true,
69
 
          'expanded'  => true,
70
 
      ));
71
 
      
72
 
      $builder->add('distro_other', 'text', array(
73
 
          'label' => 'form.reg.distro.otherlabel',
74
 
          'required'  => false,
75
 
      ));
76
 
      
77
 
      $builder->add('de', 'choice', array(
78
 
          'label' => 'form.reg.de.label',
79
 
          'choices'   => array(
80
 
              //'xfce'   => 'form.reg.de.xfce',
81
 
              'unity' => 'form.reg.de.unity',
82
 
              //'gnome' => 'form.reg.de.gnome',
83
 
              'other'   => 'form.reg.de.other',
84
 
          ),
85
 
          'required'  => true,
86
 
          'expanded'  => true,
87
 
      ));
88
 
      
89
 
      $builder->add('browser', 'choice', array(
90
 
          'label' => 'form.reg.browser.label',
91
 
          'choices'   => array(
92
 
              //'firefox'   => 'form.reg.browser.ff',
93
 
              'chrome' => 'form.reg.browser.chrome',
94
 
              'other'   => 'form.reg.browser.other',
95
 
          ),
96
 
          'data'      => $options['browser'],
97
 
          'multiple'  => true,
98
 
          'required'  => true,
99
 
          'expanded'  => true,
100
 
      ));
101
 
      
102
46
      $builder->add('gender', 'choice', array(
103
47
          'label'     => 'form.reg.gender.label',
104
48
          'choices'   => array('f' => 'form.reg.gender.female', 'm' => 'form.reg.gender.male', 'o' => 'form.reg.gender.other'),
106
50
          'expanded'  => true,
107
51
      ));
108
52
      
 
53
      $builder->add('city', 'choice', array(
 
54
          'label'     => 'form.reg.city.label',
 
55
          'choices'   => array('shanghai' => 'form.reg.city.shanghai', 'beijing' => 'form.reg.city.beijing', 'other' => 'form.reg.city.other'),
 
56
          'multiple'  => false,
 
57
          'required'  => true,
 
58
          'expanded'  => true,
 
59
      ));
 
60
      
 
61
      $builder->add('city_other', 'text', array(
 
62
          'label' => 'form.reg.city.otherlabel',
 
63
          'required'  => false,
 
64
      ));
 
65
      
109
66
      $builder->add('register', 'submit', array('label' => 'form.reg.submit'));
110
67
    }
111
68
    
118
75
    {
119
76
        $resolver->setDefaults(array(
120
77
            'email'           => '',
121
 
            'browser'         => array(),
122
78
            'error_mapping' => array(
123
 
              'isDistroValid' => 'distro',
 
79
              'isCityValid' => 'city',
124
80
              'isEmailValid' => 'email',
125
81
              'isPseudonymValid' => 'pseudonym',
126
82
             ),