Bonjour,

Je rencontre un problème lors de la personnalisation de la fiche d'inscription pour un nouvel utilisateur.

Je n'arrive pas à avoir les labels comme je les veux mais vois les labels générés par FOSUserBundle.
Par exemple, pour mes check buttons : fos_user_registration_form_howDidYouHear_1fos_user_registration_form_howDidYouHear_2fos_user_registration_form_howDidYouHear_3fos_user_registration_form_howDidYouHear_4fos_user_registration_form_howDidYouHear_5fos_user_registration_form_howDidYouHear_6fos_user_registration_form_howDidYouHear_7fos_user_registration_form_howDidYouHear_8

Pourtant dans mon formType je précise bien les labels :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
    public function buildForm(FormBuilder $builder, array $options)
    {
        // add your custom field
        $builder
            ->add('email', 'email')
            ->add('plainPassword', 'repeated', array('type' => 'password'))
            ->add('name')
            ->add('familyName', null, array(
                'label' => 'Birthday:',
            ))
            ->add('birthdate', 'birthday', array(
                'label' => 'Birthday:',
            ))
            ->add('city', null, array(
                'label' => 'City:',
            ))
            ->add('sex','choice', array(
                'choices' => array(1 => 'Male', 2 => 'Female'),
                'label' => 'Gender',
                ))
            ->add('howDidYouHear','choice', array(
                'choices' => array(
                    1 => 'Friend (verbally)',
                    2 => 'Friend (by email or text)',
                    3 => 'Received a Quilly poem',
                    4 => 'Internet news',
                    5 => 'Internet search',
                    6 => 'Internet ad',
                    7 => 'Paper and Ink press',
                    8 => 'Other'
                    ),
                'label' => 'How did you hear about The Poet ?',
                'expanded' => true,
                'multiple' => false,
                ));
    }
J'écrase aussi le fichier register_content.html.twig fourni avec le bundle, qui gère la présentation de la form. J'ai beau préciser :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
 
        {{ form_label(form.familyName, 'Family Name') }}
        {{ form_errors(form.familyName) }}
        {{ form_widget(form.familyName) }}
Ce code n'est pas non plus pris en compte..

Au final, je me retrouve à coder ma form en html dans mon fichier twig afin d'avoir des labels corrects...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    <div>
        <label for="fos_user_registration_form_city">City:</label>
        {{ form_errors(form.city) }}
        {{ form_widget(form.city) }}
    </div>
    <div>
        <label for="fos_user_registration_form_sex">Sex:</label>
        {{ form_errors(form.sex) }}
        {{ form_widget(form.sex) }}
    </div>
    <div>
        <label for="fos_user_registration_form_howDidYouHear">How did you hear about The Poet ?</label>
        <br>
        {{ form_errors(form.howDidYouHear) }}
        <input id="fos_user_registration_form_howDidYouHear_1" type="radio" value="1" required="required" name="fos_user_registration_form[howDidYouHear]">
        <label for="fos_user_registration_form_howDidYouHear_1">Friends (verbally)</label>
        <input id="fos_user_registration_form_howDidYouHear_2" type="radio" value="2" required="required" name="fos_user_registration_form[howDidYouHear]">
        <label for="fos_user_registration_form_howDidYouHear_2">Friends (by email or text)</label>
        <input id="fos_user_registration_form_howDidYouHear_3" type="radio" value="3" required="required" name="fos_user_registration_form[howDidYouHear]">
        <label for="fos_user_registration_form_howDidYouHear_3">Received a Quilly poem</label>
        <input id="fos_user_registration_form_howDidYouHear_4" type="radio" value="4" required="required" name="fos_user_registration_form[howDidYouHear]">
        <label for="fos_user_registration_form_howDidYouHear_4">Internet news</label>
        <input id="fos_user_registration_form_howDidYouHear_5" type="radio" value="5" required="required" name="fos_user_registration_form[howDidYouHear]">
        <label for="fos_user_registration_form_howDidYouHear_5">Internet search</label>
        <input id="fos_user_registration_form_howDidYouHear_6" type="radio" value="6" required="required" name="fos_user_registration_form[howDidYouHear]">
        <label for="fos_user_registration_form_howDidYouHear_6">Internet ad</label>
        <input id="fos_user_registration_form_howDidYouHear_7" type="radio" value="7" required="required" name="fos_user_registration_form[howDidYouHear]">
        <label for="fos_user_registration_form_howDidYouHear_7">Paper and Ink press</label>
        <input id="fos_user_registration_form_howDidYouHear_8" type="radio" value="8" required="required" name="fos_user_registration_form[howDidYouHear]">
        <label for="fos_user_registration_form_howDidYouHear_8">Other</label>
    </div>
Mais ça m'embête car je ne peux plus mettre le {{ form_rest(form) }}

Avez vous une idée d'où le problème peut venir ?