2 /* This file is part of Syj, Copyright (c) 2010 Arnaud Renevier,
3 and is published under the AGPL license. */
5 class Syj_Form_User extends Syj_Form_TableAbstract
7 public function init() {
8 $translator = $this->getTranslator();
10 $desc = $translator->translate("only letters, numbers, underscores or dots");
11 $name = array('Text', 'user_pseudo', array(
12 'label' => __("user name"),
13 'attribs' => array('maxlength' => '20', 'autocomplete' => 'off'),
14 'description' => $desc,
15 'validators' => array(new Zend_Validate_StringLength(0, 20),
16 new Zend_Validate_Regex('/^[a-zA-Z0-9_\.]+$/')),
20 $desc = $translator->translate("At least %d characters");
21 $desc = vsprintf($desc, 6);
22 $pass = array('Password', 'user_password', array(
23 'label' => __("password"),
25 'description' => $desc,
26 'validators' => array(new Zend_Validate_StringLength(6))
29 $pass_confirm = array('Password', 'user_password_confirm', array(
30 'label' => __("confirm password"),
31 'validators' => array(new Zend_Validate_Identical('user_password')),
35 $email = array('Text', 'user_email', array(
36 'label' => __("email"),
37 'description' => __("After creating your account, you will receive a confirmation email. You have 7 days to confirm otherwise, your account will be deleted."),
41 $this->setMainElements(array($name, $pass, $pass_confirm, $email));
43 $anchor = $this->getView()->Anchor("termsofuse?format=raw",
44 $translator->translate("terms of use"),
45 array('id' => 'user_termsofuse_anchor'));
46 $text = $translator->translate("I've read and accepted %s");
47 $text = vsprintf($text, $anchor);
48 $this->addElement('Checkbox', 'user_accept', array("label" => $text,
49 'helper' => 'SyjFormCheckbox', // similar to FormCheckbox without a hidden input
50 'decorators' => array(
53 array('HtmlTag', array('tag' => 'div', 'id' => 'user_accept_container'))),
54 'validators' => array(new Zend_Validate_Identical('1'))));
56 $decorator = $this->user_accept->getDecorator('Zend_Form_Decorator_Label');
57 $decorator->setOption('escape', false);
59 $this->addElement('Submit', 'user_submit', array('label' => __("create account")));