Bonjour,

J'ai une classe FormType et quand je soumet le formulaire même vide il passe dans le IsValid et renvoie tout le temps treu donc valide même s'il y a une erreur ....

J'ai pourtant suivi la doc officielle mais je ne vois pas pourquoi ....

Mon FormType :
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
public function buildForm(FormBuilderInterface $builder, array $options) {
        $builder
                ->add('numeroLeads', TextType::class)
                ->add('dateCreate', DateTimeType::class, array(
                    // render as a single text box
                    'widget' => 'single_text',
                    'html5' => false,
                    'format' => 'dd/MM/yyyy',
                ))
                //->add('canal', TextType::class)
                //->add('offre', TextType::class)
                //->add('statutId', StatutLeadsType::class)
                ->add('statutId', EntityType::class, array(
                    'class' => 'BackBundle:StatutLeads',
                    'query_builder' => function (StatutLeadsRepository $er) {
                        return $er->createQueryBuilder('st')
                            ->orderBy('st.statut', 'ASC');
                    },
                    'choice_label' => 'statut',
                ))
                ->add('apporteurId', ApporteurType::class)
                ->add('contacts', CollectionType::class, array(
                    'entry_type' => ClientType::class,
                    'allow_add' => true,
                    'allow_delete' => true,
                    'prototype' => true,
                    'by_reference' => false,
                    'attr' => array(
                        'class' => 'contacts-list',
                    ),
                        )
                )
                ->add('contrats', CollectionType::class, array(
                    'entry_type' => ContratType::class,
                    'allow_add' => true,
                    'allow_delete' => true,
                    'prototype' => true,
                    'by_reference' => false,
                    'attr' => array(
                        'class' => 'contrats-list',
                    ),
                        )
                )
                ->add('leadsApporteurAssociations', CollectionType::class, array(
                    'entry_type' => CommentaireLeadsType::class,
                    'allow_add' => true,
                    'allow_delete' => true,
                    'prototype' => true,
                    'by_reference' => false,
                    'attr' => array(
                        'class' => 'commentaires-list',
                    ),
                    )
                )
                ->add('leadsActionsAssociations', CollectionType::class, array(
                    'entry_type' => ActionsType::class,
                    'allow_add' => true,
                    'allow_delete' => true,
                    'prototype' => true,
                    'by_reference' => false,
                    'attr' => array(
                        'class' => 'actions-list',
                    ),
                    )
                )
        ;
    }
et un exemple d'une entité Apporteur, qui fait lien avec "->add('apporteurId', ApporteurType::class)" :
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
37
38
39
40
41
42
43
44
class Apporteur extends BaseUser {
 
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
 
    /**
     * @var string
     *
     * @ORM\Column(name="idrh", type="string", length=7, unique=true)
     * @Assert\NotBlank()
     */
    private $idrh;
 
    /**
     * @var string
     *
     * @ORM\Column(name="nom", type="string", length=255)
     * @Assert\NotBlank()
     */
    private $nom;
 
    /**
     * @var string
     *
     * @ORM\Column(name="prenom", type="string", length=255)
     * @Assert\NotBlank()
     */
    private $prenom;
 
    /**
     * @var int
     *
     * @ORM\ManyToOne(targetEntity="Etablissement")
     * @ORM\JoinColumn(name="etablissement_id", referencedColumnName="id", nullable=false)
     * @Assert\NotBlank()
     */
    private $etablissementId;
}
Une petite aide ?

Merci