全球范围内改变ZF2表格格式 [英] globally change ZF2 form formatting
问题描述
我建立从实体形式
$builder = new AnnotationBuilder( $entityManager);
$form = $builder->createForm( $entity );
这是一个很大的特点(为我节省了大量的工作),但我要的是全局更改这些形式的布局。我想用一个表格布局,而不是
This is a great feature (saves me a lot of work), but what I want is to globally change the layout of these forms. I want to use a table layout instead of
<label><span>Name:</span><input type="text" value="" name="name"></label>
我想是这样
<tr><td>Name:</td><td><input type="text"></td></tr>
这可能吗?
推荐答案
其实我错了,你并不需要真正扩展或写一个新的视图助手,实现了不同势一种渲染。
I actually was mistaken you do not need to actually extend or write a new viewHelper to achieve a diffrent kind of rendering.
在事实上 formRow
视图助手有部分参数
In fact the formRow
viewHelper has a partial parameter
公共职能__invoke(ElementInterface $元素= NULL,$ labelPosition = NULL,$ renderErrors = NULL,$部分= NULL)
在视图助手被称为与参数设置&LT;?PHP的echo $这个 - &GT; formRow($元素,空,真的,路径/要/你/部分'); ?方式&gt;
这将设置为以下变量的部分用
Once the viewHelper is called with that parameter set <?php echo $this->formRow($element, null, true, 'path/to/your/partial'); ?>
it'll set following variables for your partial to use.
'element' => $element,
'label' => $label,
'labelAttributes' => $this->labelAttributes,
'labelPosition' => $this->labelPosition,
'renderErrors' => $this->renderErrors,
现在,你只需要编写自己的标记,你应该是好去。
Now you'll only have to write your own markup and you should be good to go.
这篇关于全球范围内改变ZF2表格格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!