我正在按照Getting Started with Zend Framework 2教程学习Zend,但是我遇到了一个表单布局的问题,它坏了:

如何修复此问题,使其与本教程中的表单类似:

AlbumForm代码:
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',
'type' => 'Text',
'options' => array(
'label' => 'Title',
),
));
$this->add(array(
'name' => '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
$form->setAttribute('action', $this->url('album', array('action' => 'add')));
$form->prepare();
echo $this->form()->openTag($form);
echo $this->formHidden($form->get('id'));
echo $this->formRow($form->get('title'));
echo $this->formRow($form->get('artist'));
echo $this->formSubmit($form->get('submit'));
echo $this->form()->closeTag();发布于 2016-03-06 16:47:39
Zend Framework有可能改变元素中的样式。加上“清楚:两者都有”的风格,我认为可以解决问题?
发布于 2016-03-06 22:53:00
<div class="form_element">
<?php
$artist = $form->get('artist');
echo $this->formRow($artist);
?></div>
<div style="clear:left;"></div>
<div class="form_element">
<?php
$title = $form->get('title');
echo $this->formRow($title);
?></div>发布于 2016-03-07 00:30:31
echo '<div style="clear:both;"> </div>';
echo $this->formRow($form->get('title'));
echo '<div style="clear:both;"> </div>';
echo $this->formRow($form->get('artist'));
echo '<div style="clear:both;"> </div>';
echo $this->formSubmit($form->get('submit'));
echo '<div style="clear:both;"> </div>';https://stackoverflow.com/questions/35824677
复制相似问题