首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Zend-Framework2,表单布局已损坏

Zend-Framework2,表单布局已损坏
EN

Stack Overflow用户
提问于 2016-03-06 16:24:48
回答 4查看 50关注 0票数 0

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

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

AlbumForm代码:

代码语言:javascript
运行
复制
 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',
         ),
     ));
 }

和视图代码:

代码语言:javascript
运行
复制
<?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();
EN

回答 4

Stack Overflow用户

发布于 2016-03-06 16:47:39

Zend Framework有可能改变元素中的样式。加上“清楚:两者都有”的风格,我认为可以解决问题?

票数 0
EN

Stack Overflow用户

发布于 2016-03-06 22:53:00

代码语言:javascript
运行
复制
    <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>
票数 0
EN

Stack Overflow用户

发布于 2016-03-07 00:30:31

代码语言:javascript
运行
复制
echo '<div style="clear:both;">&nbsp;</div>';
echo $this->formRow($form->get('title'));
echo '<div style="clear:both;">&nbsp;</div>';
echo $this->formRow($form->get('artist'));
echo '<div style="clear:both;">&nbsp;</div>';
echo $this->formSubmit($form->get('submit'));
echo '<div style="clear:both;">&nbsp;</div>';
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35824677

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档