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
| <?php
class ContactForm extends sfForm
{
public function configure()
{
$this->setWidgets(array(
'Nom' => new sfWidgetFormInput(),
'Prenom' => new sfWidgetFormInput(),
'Email' => new sfWidgetFormInput(),
'Message' => new sfWidgetFormTextarea(),
));
$this->widgetSchema->setNameFormat('contact[%s]');
$this->setValidators(array(
'Nom' => new sfValidatorString(array('required' => true, 'min_length' => 3, 'max_length' => 50),
array('required' => 'Nom obligatoire', 'min_length' => 'Champ trop court', 'max_length' => 'Champ trop long')),
'Prenom' => new sfValidatorString(array('required' => true, 'min_length' => 3, 'max_length' => 50),
array('required' => 'Prenom obligatoire', 'min_length' => 'Champ trop court', 'max_length' => 'Champ trop long')),
'Email' => new sfValidatorEmail(array('required'=>true),
array('required' => 'Email obligatoire', 'invalid' => 'Adresse email invalide')),
'Message' => new sfValidatorString(array('required'=>true, 'min_length' => 4),
array('required' => 'Message obligatoire','min_length' => 'Le message est trop court'))
));
}
}
?> |
Partager