Sometimes you need to check if a field or even the entire form has errors before rendering them (e.g. when adding an errors container). Here’s the code snippet that allows you to check for the errors form variable:
{% if form.vars.errors or form.fieldName.vars.errors %} ... {% endif %}
1 Comment
Comments are closed.
Bonjour Amelieil va te falloir silmeepmnt ajouter la ligne suivante required => false,// Rend le champ facultatifdans ta description du champ au niveau du formulaireainsi tu pourra avoir $builder->add(‘nomsite’, ‘entity’, array( ‘label’ => ‘Service:’, ‘class’ => ‘CnceAnnuaireBundle:Site’, ‘property’ => ‘nomsite’, ‘required’ => false,// Rend le champ facultatif ’empty_value’ => ‘Dans tous les services’, ));