2 /* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3 and is published under the AGPL license. */
5 class Syj_Form_Account extends Zend_Form
7 protected $_decorators = array(
8 'FormElements' => array('decorator' => 'FormElements', 'options' => null),
9 'Form' => array('decorator' => 'Form', 'options' => array()));
11 protected $_elementDecorators = array(
13 'Errors' => array('decorator' => 'Errors', 'options' => array('class' => 'error')),
14 array(array('lbreak1' => 'HtmlTag'), array('tag' => 'br', 'openOnly' => true)),
16 array(array('lbreak2' => 'HtmlTag'), array('tag' => 'br', 'placement' => 'APPEND', 'openOnly' => true)),
19 public function init() {
20 $formErrors = $this->getView()->getHelper('FormErrors');
21 $formErrors->setElementStart("<div%s>")
22 ->setElementEnd("</div>")
23 ->setElementSeparator("<br>");
25 $validator = new Syj_Validate_EmailAddress();
26 $email = array('Text', 'account_email', array(
27 'label' => __("email"),
28 'validators' => array($validator),
32 $passValidator = new Zend_Validate_StringLength(6);
33 $passValidator->setMessage(vsprintf($this->getTranslator()->translate("At least %d characters"), 6));
34 $pass = array('Password', 'account_password', array(
35 'label' => __("password"),
37 'validators' => array($passValidator)));
39 $identicalValidator = new Zend_Validate_Identical('account_password');
40 $identicalValidator->setMessage(__("Password do not match"));
41 $pass_confirm = array('Password', 'account_password_confirm', array(
42 'label' => __("confirm password"),
43 'validators' => array($identicalValidator),
47 $pass_current = array('Password', 'account_password_current', array(
48 'label' => __("current password")));
50 $submit = array('Submit', 'account_submit', array('label' => __("modify my informations")));
52 $this->addElements(array($email, $pass, $pass_confirm, $pass_current, $submit));
53 $this->account_submit->setDecorators(array('ViewHelper'));
55 // fieldset around form
56 $this->addDisplayGroup(array_keys($this->_elements), 'main',
57 array('decorators' => array('FormElements',