【发布时间】:2011-11-20 04:11:40
【问题描述】:
我在 Zend Framework 中创建“三列表”表单时遇到了一些问题:
我已经有了由两列表格装饰的 Zend Form:
表格有两列,第一列用于标签,第二列用于 Zend_Form_Element,效果很好,但是, 我想添加第三列并放在那里小图像 - 问号,我将在其中设置 javascript。
如何设置装饰?
两列表格的当前装饰是:
<?php
class Application_Form_Login extends Zend_Form {
public function init() {
// create decoration for form's elements
$elementDecoration = array(
'ViewHelper',
'Description',
'Errors',
array(array('data'=>'HtmlTag'), array('tag' => 'td', 'valign' => 'TOP')),
array('Label', array('tag' => 'td')),
array('Errors'),
array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
);
$buttonDecoration = array(
'ViewHelper',
array(array('data' => 'HtmlTag'), array('tag' => 'td')),
array(array('label' => 'HtmlTag'), array('tag' => 'td', 'placement' => 'prepend')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
);
$formDecoration = array(
'FormElements',
array(array('data'=>'HtmlTag'), array('tag'=>'table', 'class'=>'forms')),
'Form'
);
// create form elements
$username = new Zend_Form_Element_Text("username");
$username->setLabel('Username: ')
->setDecorators($elementDecoration);
$password = new Zend_Form_Element_Password("password");
$password->setLabel('Password: ')
->setDecorators($elementDecoration);
$submit = new Zend_Form_Element_Submit('Login');
$submit->setLabel('LOGIN')
->setDecorators($buttonDecoration);
$this->setDecorators($formDecoration);
// set created form elements
$this->setAction('')
->setMethod('post')
->addElement($username)
->addElement($password)
->addElement($submit);
}
}
【问题讨论】:
-
你没有验证也没有投票给答案...
标签: zend-framework zend-form zend-decorators