我正在使用 ZF2 并有一个定义了一堆元素的表单,然后我将其呈现在我的 phtml 中,如下所示:
<?php
$form = $this->form;
$form->prepare();
echo $this->form()->openTag($form);
echo $this->formlabel($form->get('description'));
echo $this->formRow($form->get('radioButton'));
echo $this->form()->closeTag();
?>
它绘制了一个标签和一个单选按钮。
我的问题是如何根据自己的喜好格式化这些元素?例如,使单选按钮水平显示而不是垂直显示,并且可能更改标签的位置。
没有什么可以阻止您对它们进行格式化,您可以将元素放入列表中,或者添加您想要根据需要设置样式的任何其他标记。
<?php
$form = $this->form;
$form->prepare();
echo $this->form()->openTag($form);
?>
<ul class="form-list">
<li>
<div class="form-control">
<?php echo $this->formlabel($form->get('description')); ?>
<?php echo $this->formElementErrors($form->get('description')) ?>
<?php echo $this->formElement($form->get('description')); ?>
</div>
<div class="form-control">
<?php echo $this->formlabel($form->get('radioButton')); ?>
<?php echo $this->formElementErrors($form->get('radioButton')) ?>
<?php echo $this->formElement($form->get('radioButton')); ?>
</div>
</li>
</ul>
<?php echo $this->form()->closeTag() ?>
如果您想控制实际元素/输入本身,您可以这样做:
<label>
<?php echo $form->get('radioButton')->getLabel() ?>
<input class="bob" type="radio"
name="<?php echo $form->get('radioButton')->getName() ?>"
value="<?php echo $form->get('radioButton')->getValue() ?>"
/>
</label>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)