Bonjour,

J'ai une erreur toute bête mais je n'arrive pas à isoler le problème.

Voici quelques explications :

J'ai un formulaire de contact dans lequel la plupart des champs sont requis sauf le mail. J'ai donc indiqué dans le validator du mail "required => false".

Mais le champ mail reste pourtant requis car il est impossible d'envoyer le formulaire sans le mail.

J'ai surement fait une boulette... mais où ????
Voici le code :

ContactForm.class.php
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
class ContactForm extends BaseContactForm
{
  public function configure()
  {
      unset($this['id'], $this['created_at'], $this['updated_at'], $this['provient_web'], $this['nouveau_contact']);
 
    $this->setWidgets(array(
      'nom'             => new sfWidgetFormInputText(),
      'prenom'          => new sfWidgetFormInputText(),
      'adresse'         => new sfWidgetFormInputText(),
      'cp'              => new sfWidgetFormInputText(),
      'ville'           => new sfWidgetFormInputText(),
      'tel'             => new sfWidgetFormInputText(),
      'email'           => new sfWidgetFormInputText(),
      'message'         => new sfWidgetFormTextarea(),
      'antenne_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Antenne'), 'add_empty' => true)),
      'captcha' => new sfWidgetCaptchaGD(),
        'reference'              => new sfWidgetFormInputHidden(),
    ));
 
      $this->setValidators(array(
      'nom'    => new sfValidatorString(array(), array('required' => 'Le nom est requis.')),
      'prenom'    => new sfValidatorString(array(), array('required' => 'Le prénom est requis.')),
      'adresse'    => new sfValidatorString(array(), array('required' => 'L\'adresse est requise.')),
      'cp'    => new sfValidatorString(array(), array('required' => 'Le code postal est requis.')),
      'ville'    => new sfValidatorString(array(), array('required' => 'La ville est requise.')),
      'tel'    => new sfValidatorString(array(), array('required' => 'Le téléphone est requis.')),
      'email'           => new sfValidatorString(array(), array('max_length' => 100, 'required' => false)),
      'reference'       => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'message' => new sfValidatorString(array(),array('required' => 'Le message est requis.')),
      'antenne_id' => new sfValidatorString(array(),array('required' => 'Veuillez choisir une antenne destinataire.')),
      'captcha' => new sfCaptchaGDValidator(array('length' => 4),array('required' => 'Veuillez saisir les 4 chiffres que vous voyez sur l\'image')),
    ));
 
    $this->widgetSchema->setLabels(array('prenom' => 'Prénom', 'antenne_id' => 'Antenne destinataire', 'cp' => 'Code Postal', 'tel' => 'Téléphone'));
    $this->widgetSchema->setNameFormat('contact[%s]');
 
  }
}
Merci d'avance pour vos lumières !

cli16 -**