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
   | class ContactForm extends BaseForm
{
 protected static $civil = array('Mme'=>'Mme', 'Mlle'=>'Mlle', 'Mr'=>'M.');
 protected static $objet = array('tech'=>'Demande Technique', 'quot'=>'Quotations', 'devis'=>'Devis', 'ind'=>'Demande Industrielle', 'emplois'=>"Demande d'emplois");
 
  public function configure()
  {
    $this->setWidgets(array(
	  'societe' => new sfWidgetFormInputText(),
	  'civil' => new sfWidgetFormSelect(array('choices' => self::$civil)),
      'nom' => new sfWidgetFormInputText(),
	  'prenom' => new sfWidgetFormInputText(),
	  'fonction'  => new sfWidgetFormInputText(),
	  'tel' => new sfWidgetFormInputText(),
      'email' => new sfWidgetFormInputText(),
	  'ville' => new sfWidgetFormInputText(),
	  'CP' => new sfWidgetFormInputText(),
	  'objet' => new sfWidgetFormSelect(array('choices' => self::$objet)),
      'message' => new sfWidgetFormTextarea(),
    ));
	$this->widgetSchema->setLabels(array(
	 'societe' => 'Société',
	 'civil' => 'Civilité',
	 'nom' => 'Nom',
	 'prenom' => 'Prénom',
	 'fonction' => 'Fonction',
	 'tel' => 'Téléphone',
	 'email' => 'Email',
	 'ville' => 'Ville',
	 'CP' => 'Code Postal',
	 'objet' => 'Objet',
	 'message' => 'Votre demande',
	 ));
	$this->setValidators(array(
	    'societe' => new sfValidatorString(array('max_length' => 50),array('required' => 'Ce champs est obligatoire')),
		'civil' => new sfValidatorChoice(array('choices' => array_keys(self::$civil)),array('required' => 'Ce champs est obligatoire')),
		'nom' => new sfValidatorString(array('max_length' => 50),array('required' => 'Ce champs est obligatoire')),
		'prenom' => new sfValidatorString(array('max_length' => 50),array('required' => 'Ce champs est obligatoire')),
		'fonction' => new sfValidatorString(array('max_length' => 50),array('required' => 'Ce champs est obligatoire')),
		'tel' => new sfValidatorString(array('max_length' => 50),array('required' => 'Ce champs est obligatoire')),
		'email' => new sfValidatorEmail(array(), array('invalid' => 'Veuillez saisir une adresse mail valide.', 'required' => 'Ce champs est obligatoire')),
		'ville' => new sfValidatorString(array('max_length' => 50),array('required' => 'Ce champs est obligatoire')),
		'CP' => new sfValidatorString(array('max_length' => 50),array('required' => 'Ce champs est obligatoire')),
		'objet' => new sfValidatorChoice(array('choices' => array_keys(self::$objet)),array('required' => 'Ce champs est obligatoire')),
		'message' => new sfValidatorString(array('max_length' => 255),array('required' => 'Ce champs est obligatoire')),
	));	
	$this->widgetSchema->setNameFormat('contact[%s]');
  }
} | 
Partager