使用Zend_Form,有可能有4列吗? 示例:
<table>
<tr>
<td>Element 1 label</td>
<td>element1</td>
<td>Element 2 label</td>
<td>element2</td>
</tr>
</table>
感谢。
答案 0 :(得分:1)
烨!
viewScript Decorator
是你的朋友。
//the viewScript
<article class="login">
<form action="<?php echo $this->element->getAction() ?>"
method="<?php echo $this->element->getMethod() ?>">
<table>
<tr>
<th>Login</th>
<tr>
//renders just the Label decorator
<td><?php echo $this->element->name->renderLabel() ?></td>
//renders just the viewHelper decorator
<td><?php echo $this->element->name->renderViewHelper() ?></td>
</tr>
<tr>
//renders just the Label decorator
<td><?php echo $this->element->password->renderLabel() ?></td>
//renders just the viewHelper decorator
<td><?php echo $this->element->password->renderViewHelper() ?></td>
</tr>
<tr>
//renders the entire element
<td><?php echo $this->element->submit ?></td>
</tr>
</table>
</form>
</article>
表格
<?php
class Application_Form_Login extends Zend_Form
{
public function init() {
$this->setMethod('POST');
$this->setAction('/index/login');
/**
* Set the viewScript decorator
*/
$this->setDecorators(array(
array('ViewScript', array(
'viewScript' => '_login.phtml'
))
));
/**
* Text element 'name'
*/
$name = new Zend_Form_Element_Text('name');
$name->setLabel('Name');
$name->setAttrib('placeholder', 'Username');
$name->setOptions(array('size' => 20));
/**
* Password element for 'password'
*/
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password');
$password->setAttrib('placeholder', 'Password');
$password->setOptions(array('size' => 20));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Login');
$this->addElements(array($name, $password, $submit));
}
}
希望这有帮助。