【问题标题】:Do not show collection number不显示收藏编号
【发布时间】:2015-04-10 07:38:26
【问题描述】:

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

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

我的表单“CommentType”只有一个输入 cmets 的字段:

$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

如何禁用此控件标签?

更新

【问题讨论】:

  • 创建控制标签是什么意思?你有图片或html吗?
  • @nawfal-serrar 我添加了一张图片。控制标签是一个附加项目。我认为这是在集合中自动生成的,但我不想要它:)

标签: symfony


【解决方案1】:

为你的收藏添加optionslabel属性,如下

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2015-02-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-18
      • 1970-01-01
      • 2018-07-19
      • 1970-01-01
      相关资源
      最近更新 更多