2013-01-11 37 views
1

我有一個使用Zend \ Form \ Annotation創建的Zend表單。我使用下面的代碼來生成HTML:Zend框架中的表單字段和標籤位置2

echo $this->form()->openTag($form); 
echo $this->formCollection($form); 
echo $this->form()->closeTag(); 

問題是標籤只是輸入文本字段,如在此之前放置:
標籤:文本輸入框

我想做的事情是這樣的:
標籤:
文本輸入框

我如何格式化我的標籤,讓我想要的位置?

回答

3

我所要做的是使用,而不是使用像下面的FormCollection方法各個元素打印:

<dl class="zend_form"> 
    <?php echo $this->formElementErrors($form->get('identity')) ?> 

    <dt><?php echo $this->formLabel($form->get('identity')) ?></dt> 
    <dd><?php echo $this->formInput($form->get('identity')) ?></dd> 

    <dt><?php echo $this->formLabel($form->get('credential')) ?></dt> 
    <dd><?php echo $this->formInput($form->get('credential')) ?></dd> 

    <?php if ($this->redirect): ?> 
     <input type="hidden" name="redirect" value="<?php echo $this->redirect ?>" /> 
    <?php endif ?> 

    <dd><?php echo $this->formButton($form->get('submit')) ?></dd> 
</dl> 
1

你只可以使用CSS:

label { 
    display: block; 
} 
0

只需要給元素的ID在您的註釋類似@Annotation \ Attributes({「id」:「id」})