不要显示收集号码

时间:2015-04-10 07:38:27

标签: symfony

我有一个带有集合的“调查”表单。

->add('comments', 'collection', array(
                        'type'         => new CommentType() ,
                        'allow_add'    => false,
                        'allow_delete' => false,
                        'label'        => false,
                    )
                )

我的表单“CommentType”只有一个用于输入注释的字段:

$builder->add('comment', 'text', array('label'  => 'comment', 'translation_domain' => 'messages', 'attr' => array('maxlength' => 255)));

如果我在像这样的树枝模板中渲染我的收藏

{{ form_row(form.comments, {'attr': {}}) }}

Symfony / Twig始终使用渲染集合的数字呈现控件标签“control-label required”。

例如:

0 -> control-label required
Comment -> Label
[] -> Input field

1 -> control-label required
Comment -> Label
[] -> Input field

如何禁用此控件标签?

更新

Show comment list with auto generated label

2 个答案:

答案 0 :(得分:0)

为您的收藏添加optionslabel属性,如下所示

->add('comments', 'collection', array(
        'type'         => new CommentType() ,
        'allow_add'    => false,
        'allow_delete' => false,
        'options'      => array(
                'label' => false,
        )
     )

答案 1 :(得分:0)

我认为您停用了错误的标签,保留了该集合的标签并禁用了->add('comment','text'.....)

中的标签