一个Zend_Form的完整装饰
-
1
class My_Form_Registration extends Zend_Form
2
{
3
public $elementDecorators = array(
4
'ViewHelper',
5
'Errors',
6
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
7
array('Label', array('tag' => 'td'),
8
array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
9
);
10![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
public $buttonDecorators = array(
12
'ViewHelper',
13
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
14
array(array('label' => 'HtmlTag'), array('tag' => 'td', 'placement' => 'prepend')),
15
array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
16
);
17![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
18
public function init()
19
{
20
$this->addElement('text', 'username', array(
21
'decorators' => $this->elementDecorators,
22
'label => 'Username:',
23
);
24
$this->addElement('text', 'firstname', array(
25
'decorators' => $this->elementDecorators,
26
'label => 'First Name:',
27
);
28
$this->addElement('text', 'lastname', array(
29
'decorators' => $this->elementDecorators,
30
'label => 'Last Name:',
31
);
32
$this->addElement('submit', 'save', array(
33
'decorators' => $this->buttonDecorators,
34
'label => 'Save',
35
);
36
}
37![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
38
public function loadDefaultDecorators()
39
{
40
$this->setDecorators(array(
41
'FormElements',
42
array('HtmlTag', array('tag' => 'table')),
43
'Form',
44
));
45
}
46
}
47![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
32
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
34
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
36
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
37
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
38
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
39
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
40
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
42
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
43
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
44
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
45
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
46
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
47
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://www.cnblogs.com/Emoticons/baimantou/202015934.gif)