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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| class ProfilForm extends Zend_Form
{
public function init()
{
/*$this->addPrefixPath('forms_validators',
'../application/forms/validators',
'validate');*/
$this->setAttrib("id", "formModif");
###################################################################
$password = new Zend_Form_Element_Password('password');
$password->renderPassword = true;
$password->setAttrib("maxlength", "30");
$password->setAttrib("size", "30");
$password->setLabel("Mot de passe : ");
$password->setRequired(true);
//$password->setAllowEmpty(true);
$password->setAttrib("onclick","document.getElementById('password').value = ''");
$userNotEmpty = new Zend_Validate_NotEmpty();
$userNotEmpty->setMessage('Le mot de passe est requis et ne doit pas être vide.', Zend_Validate_NotEmpty::IS_EMPTY);
$filterTrim = new Zend_Filter_StringTrim();
$password->setFilters(array($filterTrim));
$validLength = new Zend_Validate_StringLength(6, 30);
$validLength->setMessage("Le mot de passe est trop court (6 minimum)", Zend_Validate_StringLength::TOO_SHORT);
$validLength->setMessage("Le mot de passe trop long", Zend_Validate_StringLength::TOO_LONG);
$validLength->setMessage("Le mot de passe doit être de type <string>", Zend_Validate_StringLength::INVALID);
$password->addValidator($userNotEmpty);
$password->addValidator($validLength);
$this->addElement($password);
###################################################################
###################################################################
$password2 = new Zend_Form_Element_Password('password2');
$password2->renderPassword = true;
$password2->setAttrib("maxlength", "30");
$password2->setAttrib("size", "30");
$password2->setLabel("Mot de passe (Confirmation): ");
$password2->setRequired(true);
$password2->setAttrib("onclick","document.getElementById('password2').value = '';");
$userNotEmpty = new Zend_Validate_NotEmpty();
$userNotEmpty->setMessage('Le mot de passe est requis et ne doit pas être vide.', Zend_Validate_NotEmpty::IS_EMPTY);
$filterTrim = new Zend_Filter_StringTrim();
$password2->setFilters(array($filterTrim));
$validLength = new Zend_Validate_StringLength(6, 30);
$validLength->setMessage("Le mot de passe est trop court (6 minimum)", Zend_Validate_StringLength::TOO_SHORT);
$validLength->setMessage("Le mot de passe trop long", Zend_Validate_StringLength::TOO_LONG);
$validLength->setMessage("Le mot de passe doit être de type <string>", Zend_Validate_StringLength::INVALID);
$password2->addValidator($userNotEmpty);
$password2->addValidator($validLength);
$this->addElement($password2);
###################################################################
/*APPEL AU VALIDATEUR FOIREUX*/
$password->addValidator(new MyPasswordValidator($password2));
$createPlanif = $this->addElement('submit', 'utilisateur', array(
'required' => false,
'ignore' => true,
'label' => 'Modifier les données du profil',
));
$this->addDisplayGroup(array("password", "password2", 'utilisateur'), 'monProfil');
$this->getDisplayGroup('monProfil')->setLegend("Modification du mot de passe");
}
} |
Partager