]> dev.renevier.net Git - syj.git/blob - application/forms/Account.php
redirection after path creation is decided by server (php), not guessed by client...
[syj.git] / application / forms / Account.php
1 <?php
2 /*  This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3     and is published under the AGPL license. */
4
5 class Syj_Form_Account extends Zend_Form
6 {
7     protected $_decorators = array(
8                             'FormElements' => array('decorator' => 'FormElements', 'options' => null),
9                             'Form' => array('decorator' => 'Form', 'options' => array()));
10
11     protected $_elementDecorators = array(
12                                 'ViewHelper',
13                                 'Errors' => array('decorator' => 'Errors', 'options' => array('class' => 'error')),
14                                 array(array('lbreak1' => 'HtmlTag'), array('tag' => 'br', 'openOnly' => true)),
15                                 'Label',
16                                 array(array('lbreak2' => 'HtmlTag'), array('tag' => 'br', 'placement' => 'APPEND', 'openOnly' => true)),
17                                 );
18
19     public function init() {
20         $formErrors = $this->getView()->getHelper('FormErrors');
21         $formErrors->setElementStart("<div%s>")
22                    ->setElementEnd("</div>")
23                    ->setElementSeparator("<br>");
24
25         $validator = new Syj_Validate_EmailAddress();
26         $email = array('Text', 'account_email', array(
27             'label' => __("email"),
28             'validators' => array($validator),
29             'maxlength' => '320',
30             'required' => true));
31
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"),
36             'required' => true,
37             'validators' => array($passValidator)));
38
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),
44                 'allowEmpty' => false
45         ));
46
47         $pass_current = array('Password', 'account_password_current', array(
48                 'label' => __("current password")));
49
50         $submit = array('Submit', 'account_submit', array('label' => __("modify my informations")));
51
52         $this->addElements(array($email, $pass, $pass_confirm, $pass_current, $submit));
53         $this->account_submit->setDecorators(array('ViewHelper'));
54
55         // fieldset around form
56         $this->addDisplayGroup(array_keys($this->_elements), 'main',
57             array('decorators' => array('FormElements',
58                                  array('fieldset'))));
59
60     }
61 }