1

我有一个使用 Zend\Form\Annotation 创建的 Zend 表单。我正在使用以下代码生成 HTML:

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

问题是标签放置在输入文本字段之前,如下所示:
标签:输入文本框

我想这样做:
标签:
输入文本框

如何格式化我的标签以获得我想要的位置?

4

3 回答 3

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>
于 2013-01-11T06:03:51.720 回答
1

你可以使用css:

label {
    display: block;
}
于 2013-01-11T08:55:13.830 回答
0

just give the elements an id in your annotation like @Annotation\Attributes({"id" : "id"})

于 2014-01-08T00:57:58.037 回答