]> dev.renevier.net Git - syj.git/blob - application/forms/User.php
version 0.1
[syj.git] / application / forms / User.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_User extends Syj_Form_TableAbstract
6 {
7     public function init() {
8         $translator = $this->getTranslator();
9
10         $name = array('Text', 'user_pseudo', array(
11             'label' => __("user name"),
12             'attribs' => array('maxlength' => '20'),
13             'validators' => array(new Zend_Validate_StringLength(0, 20),
14                                  new Zend_Validate_Regex('/^[a-zA-Z0-9_\.]+$/')),
15             'required' => true
16         ));
17
18         $desc = $translator->translate("At least %d characters");
19         $desc = vsprintf($desc, 6);
20         $pass = array('Password', 'user_password', array(
21             'label' => __("password"),
22             'required' => true,
23             'description' => $desc,
24             'validators' => array(new Zend_Validate_StringLength(6))
25         ));
26
27         $pass_confirm = array('Password', 'user_password_confirm', array(
28                 'label' => __("confirm password"),
29                 'validators' => array(new Zend_Validate_Identical('user_password')),
30                 'required' => true
31         ));
32
33         $email = array('Text', 'user_email', array(
34             'label' => __("email"),
35             'description' => __("After creating your account, you will receive a confirmation email. You have 7 days to confirm otherwise, your account and your routes will all be deleted."),
36             'required' => true
37             ));
38
39         $this->setMainElements(array($name, $pass, $pass_confirm, $email));
40
41         $anchor = $this->getView()->Anchor("termsofuse", $translator->translate("terms of use"), array('id' => 'user_termsofuse_anchor'));
42         $text = $translator->translate("I've read and accepted %s");
43         $text = vsprintf($text, $anchor);
44         $this->addElement('Checkbox', 'user_accept', array("label" => $text,
45                             'decorators' => array(
46                                   'ViewHelper',
47                                   'label',
48                                   array('HtmlTag', array('tag' => 'div'))),
49                             'validators' => array(new Zend_Validate_Identical('1'))));
50
51         $decorator = $this->user_accept->getDecorator('Zend_Form_Decorator_Label');
52         $decorator->setOption('escape', false);
53
54         $this->addElement('Submit', 'user_submit', array('label' => __("create account")));
55     }
56 }