To validate my class DeclarationForm :
class DeclarationForm {
private $identifiant;
private $qualiteInterlocuteur;
private $nomCible;
private $reference;
private $description;
private $traitement;
private $commentaire;
}
I use a validation.yml in the bundle :
xxx\MyBundle\Form\DeclarationForm:
properties:
nomCible:
- NotBlank: { message: 'not good' }
description:
- NotBlank: { message: 'not good' }
I checked the app/config.yml
framework:
validation: { enabled: true }
It is like validation.yml does not exist. form->isValid() returns true
$declaration_form = new DeclarationForm();
$form = $this->createForm(new DeclarationType($this->get('translator'), array(
'phase' => $phase,
'params_qualities' => $params
)), $declaration_form);
$form->handleRequest($request);
if($form->isValid()) {
....
}
I modified the code not to use isValid :
$validator = $this->get('validator');
$liste_erreurs = $validator->validate($declaration_form);
if(count($liste_erreurs) === 0)
It works !!
So the problem is (isValid). I dont understand why it does not work