title: How do the symfony required option work?
body: <p>I don't know why, but I remembered that when you have a symfony form with required fields not rendered, the <code>isValid</code> function do not check for them.</p>
  
  <p>I mean it only check if the widget got a value when you use it. And it seem in my current project that it is wrong.</p>
  
  <p>Is there a setting or something allowing to do this ?</p>
  
  <p>Edit : Here is the form :</p>
  
  <pre><code>    class DemandeForm extends BaseDemandeForm
      {
    public function configure()
    {
      $this-&gt;widgetSchema['DEMANDE_DESC']         = new sfWidgetFormTextarea();
      $this-&gt;validatorSchema['DEMANDE_DESC']      = new sfValidatorString(array('required' =&gt; true),
      array("required" =&gt; str_replace('$1','Description de la demande',MessagePeer::getFrameworkMessageFromNum(7))));
  
      $this-&gt;validatorSchema['DEMANDE_LIB']      = new sfValidatorString(array('required' =&gt; true),
      array("required" =&gt; str_replace('$1','Libelle de la demande',MessagePeer::getFrameworkMessageFromNum(7))));
  
      $this-&gt;widgetSchema['TIERS_ID']         = new crfcWidgetAutocomplete();
      $this-&gt;validatorSchema['TIERS_ID']      = new sfValidatorString(array('required' =&gt; true),
      array("required" =&gt; str_replace('$1','Tiers',MessagePeer::getFrameworkMessageFromNum(7))));
  
      $bat_choices = $this-&gt;getOption('bat_choices');
      $this-&gt;widgetSchema['BAT_CODE']         = new sfWidgetFormChoice(array('choices' =&gt; $bat_choices , 'expanded' =&gt; false, 'multiple' =&gt; false));
      $this-&gt;validatorSchema['BAT_CODE']      = new sfValidatorChoice(array('choices' =&gt; array_keys($bat_choices),'required' =&gt; false)
      );
  
      $local_choices = $this-&gt;getOption('local_choices');
      $this-&gt;widgetSchema['LOCAL_CODE']       = new sfWidgetFormChoice(array('choices' =&gt; $local_choices, 'expanded' =&gt; false, 'multiple' =&gt; false));
      $this-&gt;validatorSchema['LOCAL_CODE']    = new sfValidatorChoice(array('choices' =&gt; array_keys($local_choices),'required' =&gt; false)
      );
  
      $site_choices = $this-&gt;getOption('site_choices');
      $this-&gt;widgetSchema['SITE_CODE']       = new sfWidgetFormChoice(array('choices' =&gt; $site_choices, 'expanded' =&gt; false, 'multiple' =&gt; false));
      $this-&gt;validatorSchema['SITE_CODE']    = new sfValidatorChoice(array('choices' =&gt; array_keys($site_choices),'required' =&gt; false)
      );
  
      $ress = Array(""=&gt;"") + EnumereValeurPeer::getByType('FONCTIONS',true);
      $this-&gt;widgetSchema['FONCTION_EVAL_NUMINT']         = new sfWidgetFormChoice(array('choices' =&gt; $ress , 'expanded' =&gt; false, 'multiple' =&gt; false));
      $this-&gt;validatorSchema['FONCTION_EVAL_NUMINT']      = new sfValidatorChoice(array('choices' =&gt; array_keys($ress),'required' =&gt; false),
      array("required" =&gt; str_replace('$1','Fonction demandeur',MessagePeer::getFrameworkMessageFromNum(7))));
  
      $ress = Array(""=&gt;"") + EnumereValeurPeer::getByType('CIRCONSTANCE',true);
      $this-&gt;widgetSchema['CIRCONSTANCE_EVAL_NUMINT']       = new sfWidgetFormChoice(array('choices' =&gt; $ress, 'expanded' =&gt; false, 'multiple' =&gt; false));
      $this-&gt;validatorSchema['CIRCONSTANCE_EVAL_NUMINT']    = new sfValidatorChoice(array('choices' =&gt; array_keys($ress),'required' =&gt; false),
      array("required" =&gt; str_replace('$1','Circonstance de la demande',MessagePeer::getFrameworkMessageFromNum(7))));
  
      $ress = Array(""=&gt;"") + EnumereValeurPeer::getByType('TRAVAUX',true);
      $this-&gt;widgetSchema['CATEGORIE_EVAL_NUMINT']         = new sfWidgetFormChoice(array('choices' =&gt; $ress , 'expanded' =&gt; false, 'multiple' =&gt; false));
      $this-&gt;validatorSchema['CATEGORIE_EVAL_NUMINT']      = new sfValidatorChoice(array('choices' =&gt; array_keys($ress),'required' =&gt; false),
          array("required" =&gt; str_replace('$1','Catégorie de travaux',MessagePeer::getFrameworkMessageFromNum(7)))
      );
  
      $ress = Array(""=&gt;"") + EnumereValeurPeer::getByType('QUALIFICATION',true);
      $this-&gt;widgetSchema['QUALIFICATION_EVAL_NUMINT']         = new sfWidgetFormChoice(array('choices' =&gt; $ress , 'expanded' =&gt; false, 'multiple' =&gt; false));
      $this-&gt;validatorSchema['QUALIFICATION_EVAL_NUMINT']      = new sfValidatorChoice(array('choices' =&gt; array_keys($ress),'required' =&gt; true),
          array("required" =&gt; str_replace('$1','Qualification',MessagePeer::getFrameworkMessageFromNum(7)))
      );
  
      $ress = Array(""=&gt;"") + EnumereValeurPeer::getByType('PROGRAMME',true);
      $this-&gt;widgetSchema['PROGRAMME_EVAL_NUMINT']         = new sfWidgetFormChoice(array('choices' =&gt; $ress , 'expanded' =&gt; false, 'multiple' =&gt; false));
      $this-&gt;validatorSchema['PROGRAMME_EVAL_NUMINT']      = new sfValidatorChoice(array('choices' =&gt; array_keys($ress),'required' =&gt; true),
              array("required" =&gt; str_replace('$1','Programme',MessagePeer::getFrameworkMessageFromNum(7)))
              );
  
      $ress = Array(""=&gt;"") + EnumereValeurPeer::getByType('SUPPORT',true);
      $this-&gt;widgetSchema['SUPPORT_EVAL_NUMINT']         = new sfWidgetFormChoice(array('choices' =&gt; $ress , 'expanded' =&gt; false, 'multiple' =&gt; false));
      $this-&gt;validatorSchema['SUPPORT_EVAL_NUMINT']      = new sfValidatorChoice(array('choices' =&gt; array_keys($ress),'required' =&gt; false),
      array("required" =&gt; str_replace('$1','Support',MessagePeer::getFrameworkMessageFromNum(7))));
  
      $this-&gt;widgetSchema['COMMENTAIRE']         = new sfWidgetFormTextarea();
      $this-&gt;validatorSchema['COMMENTAIRE']      = new sfValidatorString(array('required' =&gt; false));
  
  
      $this-&gt;widgetSchema['DEMANDE_DTDEM']                    = new myWidgetFormRichDate();
      $this-&gt;validatorSchema['DEMANDE_DTDEM']                 = new sfValidatorDate(array('required' =&gt; true, 'date_format'=&gt;'@(?P&lt;day&gt;\d{2})/(?P&lt;month&gt;\d{2})/(?P&lt;year&gt;\d{4})@'),
          array('required'=&gt; str_replace('$1','Date de la demande',MessagePeer::getFrameworkMessageFromNum(7)),
          'bad_format' =&gt; str_replace('$1','Date de la demande',MessagePeer::getFrameworkMessageFromNum(19)),
          'invalid' =&gt; str_replace('$1','Date de la demande',MessagePeer::getFrameworkMessageFromNum(19))));
  
      $this-&gt;widgetSchema['DEMANDE_DTFIN']                    = new myWidgetFormRichDate();
      $this-&gt;validatorSchema['DEMANDE_DTFIN']                 = new sfValidatorDate(array('required' =&gt; true, 'date_format'=&gt;'@(?P&lt;day&gt;\d{2})/(?P&lt;month&gt;\d{2})/(?P&lt;year&gt;\d{4})@'),
          array('required'=&gt; str_replace('$1','Date de fin des travax souhaitée',MessagePeer::getFrameworkMessageFromNum(7)),
          'bad_format' =&gt; str_replace('$1','Date de fin des travax souhaitée',MessagePeer::getFrameworkMessageFromNum(19)),
          'invalid' =&gt; str_replace('$1','Date de fin des travax souhaitée',MessagePeer::getFrameworkMessageFromNum(19))));
  
      $this-&gt;widgetSchema['DEMANDE_ACCESSIBILITE']            = new sfWidgetFormInputCheckbox();
      $this-&gt;validatorSchema['DEMANDE_ACCESSIBILITE']         = new sfValidatorBoolean(array('required' =&gt; false));
  
      $this-&gt;widgetSchema['DEMANDE_URGENT']                   = new sfWidgetFormInputCheckbox();
      $this-&gt;validatorSchema['DEMANDE_URGENT']                = new sfValidatorBoolean(array('required' =&gt; false));
  
      $this-&gt;widgetSchema['DEMANDE_INCENDIE']                 = new sfWidgetFormInputCheckbox();
      $this-&gt;validatorSchema['DEMANDE_INCENDIE']              = new sfValidatorBoolean(array('required' =&gt; false));
  
      $this-&gt;validatorSchema-&gt;setOption('allow_extra_fields' , true);
      $this-&gt;validatorSchema-&gt;setOption('filter_extra_fields' , false);
    }
  
  
  }
  </code></pre>
  
  <p>Edit 2 : </p>
  
  <p>The question is : is it normal than the DEMANDE_DTDEM field required, raise a required form field error, whereas he hadn't been rendered ?</p>
  
  <p>Shouldn't a form field be validated only when he was used ?</p>