2016-03-06 71 views
0

我按照Getting Started with Zend Framework 2教程,但我面臨的形式佈局的prolem學習Zend公司,它的分解: enter image description here的Zend-Framework2,窗體佈局是殘破

如何解決這個問題,使之喜形式在教程: enter image description here

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

回答

0

Zend Framework有可能改變元素的風格。添加「明確:兩者」;風格我認爲會解決問題?

+0

它不起作用。 –

0
<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

抱歉,但它不能再工作。我編輯了這個問題來添加我的代碼。請幫忙查看。 –

0
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

在本教程中,標籤和框位於2個單獨的行中。做你的代碼只是打破「標題」和「藝術家」,但不能打破標籤和框。 –

0

的最簡單和最快的方式是添加這個CSS ..

form label 
{ 
    display: block; 
} 

注意,這將是從本教程稍有不同。