Php 使用formRow时以内联方式显示的元素
我在代码中使用了formrow(),但它没有给出正确的结果。元素以内联方式显示,而不是显示在新行上 表格编号: 使用Zend\Form\Form; 使用Zend\Form\View\Helper\FormRowPhp 使用formRow时以内联方式显示的元素,php,zend-framework2,zend-form,Php,Zend Framework2,Zend Form,我在代码中使用了formrow(),但它没有给出正确的结果。元素以内联方式显示,而不是显示在新行上 表格编号: 使用Zend\Form\Form; 使用Zend\Form\View\Helper\FormRow class AlbumForm extends Form { public function __construct($name = null) { // we want to ignore the name passed parent::
class AlbumForm extends Form
{
public function __construct($name = null)
{
// we want to ignore the name passed
parent::__construct('album');
$this->add(array(
'name' => 'id',
'type' => 'Hidden',
));
$this->add(array(
'name' => 'title',
'id' => 'title',
'type' => 'Text',
'options' => array(
'label' => 'Title',
),
));
$this->add(array(
'name' => 'artist',
'id' => 'artist',
'type' => 'Text',
'options' => array(
'label' => 'Artist',
),
));
$this->add(array(
'name' => 'submit',
'type' => 'Submit',
'attributes' => array(
'value' => 'Go',
'id' => 'submitbutton',
),
));
}
}
视图:
你知道这是一个纯粹的HTML/CSS问题吗?如果您想更改HTML布局,您需要实现自己的ViewHelper,如果您只是想稍微更改布局(听起来就是这样),CSS就是您所需要的一切…谢谢Sam!我会调查的。
<?php
// module/Album/view/album/album/add.phtml:
$title = 'Add new album';
$this->headTitle($title);
?>
<h1><?php echo $this->escapeHtml($title); ?></h1>
<?php
$this->form->setAttribute('action', $this->url('album', array('action' => 'add')));
$this->form->prepare();
echo $this->form()->openTag($this->form);
echo $this->formHidden($this->form->get('id'));
echo $this->formRow($this->form->get('title'));//echo "<br/>";
echo $this->formRow($this->form->get('artist'));//echo "<br/>";
echo $this->formSubmit($this->form->get('submit'));
echo $this->form()->closeTag();
//echo $this->formCollection($form);