]> dev.renevier.net Git - syj.git/blob - application/forms/Geom.php
3d99a87bd6014b7522b2bee84c7bef81439be960
[syj.git] / application / forms / Geom.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_Geom extends Zend_Form
6 {
7     protected $_elementDecorators = array( 'ViewHelper', 'Errors',);
8
9     protected $_decorators = array(
10                             'FormElements' => array('decorator' => 'FormElements', 'options' => null),
11                             'Form' => array('decorator' => 'Form', 'options' => null)
12                             );
13
14     public function init() {
15         $data = array('Hidden', 'geom_data', array('required' => true));
16
17         $title = array('Text', 'geom_title', array(
18             'label' => __("optional title for this journey"),
19             'attribs' => array('maxlength' => '40', 'size' => '20'),
20             'validators' => array(new Zend_Validate_StringLength(0, 40))
21             ));
22
23         $translator = $this->getTranslator();
24         $anchor = $this->getView()->Anchor("termsofuse?format=raw",
25                                            $translator->translate("terms of use"),
26                                            array('id' => 'geom_termsofuse_anchor'));
27         $text = $translator->translate("I've read and accepted %s");
28         $text = vsprintf($text, $anchor);
29         $touaccept = array('Checkbox', 'geom_accept', array("label" => $text,
30                             'helper' => 'SyjFormCheckbox', // similar to FormCheckbox without a hidden input
31                             'decorators' => array(
32                                   'ViewHelper',
33                                   'label',
34                                   array('HtmlTag', array('tag' => 'div', 'id' => 'geom_accept_container', 'class' => 'logged-hide')))));
35
36         $submit = array('Submit', 'geom_submit', array('label' => __("save")));
37
38         $this->addElements(array($data, $title, $touaccept, $submit));
39
40         $decorator = $this->geom_accept->getDecorator('Zend_Form_Decorator_Label');
41         $decorator->setOption('escape', false);
42
43         $this->geom_title->addDecorator('HtmlTag', array('tag' => 'br', 'openOnly' => true))->
44             addDecorator('label');
45         $this->geom_submit->addDecorator('HtmlTag', array('tag' => 'br', 'openOnly' => true));
46
47     }
48 }