Bonjour
Je n'arrive pas à afficher un simple label avec zend_form_element.
il y a tout sauf le zend_form_element_label.
Je fais comment?
Merci.
Version imprimable
Bonjour
Je n'arrive pas à afficher un simple label avec zend_form_element.
il y a tout sauf le zend_form_element_label.
Je fais comment?
Merci.
Bonjour,
Voici un exemple tout simple
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 class Form_Heures extends Zend_Form{ public function __construct($options = null,$edit = null){ parent::__construct($options); $this->setName('Fixer heures'); $nom = new Zend_Form_Element_Text('heures'); $nom -> setLabel('Heures') ->setRequired(true) ->setValue($edit['heures']) ->addValidator('NotEmpty'); $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Suivant'); $this->addElements(array($nom,$submit)); $this->clearDecorators(); $this->addDecorator('FormElements') ->addDecorator('HtmlTag', array('tag' => '<fieldset>')) ->addDecorator('Form'); $this->setElementDecorators(array( array('ViewHelper'), array('Errors',array('class'=>'error')), array('Label', array('separator'=>' ')), array('HtmlTag', array('tag' => 'p')), )); // buttons do not need labels $submit->setDecorators(array( array('ViewHelper'), array('HtmlTag', array('tag' => 'p')), )); } }