虽然使用了formRow,但元素内联

时间:2014-03-27 07:38:30

标签: 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::__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',
                ),
        ));
    }
}

查看:

<?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);

0 个答案:

没有答案