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
| //ContactForm.class.php
class ContactForm extends sfForm
{
protected static $subjects = array(' ' => '(Choisissez le sujet)', 'Devis' => 'Demande de devis', 'Rendez-vous' => 'Rendez-vous', 'Autres' => 'Autres...');
public function configure()
{
//unset($this->widgetSchema['_csrf_token']);
// $this->disableCSRFProtection();
$this->setWidgets(array(
'nom' => new sfWidgetFormInputText(array(), array('class' => 'input_petit', 'type' => 'text', 'onFocus' => "input_focus(this, 'Nom ');", 'onBlur' => "input_blur(this, 'Nom ');", 'required' => 'required', 'maxlength' => '30', 'pattern' => '[a-zA-Z ]{3,}')),
'prenom' => new sfWidgetFormInputText(array(), array('class' => 'input_petit', 'type' => 'text', 'onFocus' => "input_focus(this, 'Prénom');", 'onBlur' => "input_blur(this, 'Prénom');", 'required' => 'required', 'maxlength' => '30', 'pattern' => '[a-zA-Z ]{3,}')),
'mail' => new sfWidgetFormInputText(array(), array('class' => 'input_moyen', 'type' => 'email', 'onFocus' => "input_focus(this, 'Adresse email');", 'onBlur' => "input_blur(this, 'Adresse email');", 'maxlength' => '30')),
'telephone' => new sfWidgetFormInputText(array(), array('class' => 'input_moyen', 'type' => 'text', 'onFocus' => "input_focus(this, 'Téléphone');", 'onBlur' => "input_blur(this, 'Téléphone');", 'required' => 'required', 'maxlength' => '30', 'pattern' => '([0-9]+[ -_/])*[0-9]+')),
'sujet' => new sfWidgetFormSelect(array('choices' => self::$subjects), array('class' => 'input_select')),
'titre' => new sfWidgetFormInputText(array(), array('class' => 'input_grand', 'type' => 'text', 'onFocus' => "input_focus(this, 'Titre');", 'onBlur' => "input_blur(this, 'Titre');", 'required' => 'required', 'maxlength' => '30', 'pattern' => '[a-zA-Z ]{3,}')),
'contenu' => new sfWidgetFormTextarea(array(), array('class' => 'input_textarea')),
));
$this->setValidators(array(
'nom' => new sfValidatorString(array('required' => true, 'min_length' => 2, 'max_length' => 20), array('required' => 'Veuillez indiquer votre nom ','min_length' => 'Un minimum de deux caractères est requis.', 'max_length' => 'Un maximum de vingt caractères est requis.')),
'prenom' => new sfValidatorString(array('required' => true, 'min_length' => 2, 'max_length' => 20), array('required' => 'Veuillez indiquer votre prénom ','min_length' => 'Un minimum de deux caractères est requis.', 'max_length' => 'Un maximum de vingt caractères est requis.')),
'mail' => new sfValidatorEmail(array('min_length' => 2, 'max_length' => 20), array('required' => 'L\'adresse mail est requise pour valider le formulaire', 'invalid' => 'Vérifiez que l\'adresse a été correctement tapée.')),
'telephone' => new sfValidatorString(array('required' => true), array('required' => 'Veuillez indiquer votre numéro de téléphone ')),
'sujet' => new sfValidatorString(array('required' => true), array('required' => 'Veuillez indiquer un sujet')),
'titre' => new sfValidatorString(array('required' => true, 'min_length' => 2, 'max_length' => 255), array('required' => 'Veuillez indiquer un titre ','min_length' => 'Un minimum de deux caractères est requis.', 'max_length' => 'Un maximum de vingt caractères est requis.')),
'contenu' => new sfValidatorString(array('required' => true), array('required' => 'Le contenu du mail est requis pour valider le formulaire')),
));
$this->setDefaults(array(
'nom' => 'Nom ',
'prenom' => 'Prénom',
'mail' => 'Adresse email',
'telephone' => 'Téléphone',
'titre' => 'Titre',
));
$this->widgetSchema->setNameFormat('contacta[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
}
} |
Partager