从原型名称中删除'label__'

时间:2015-01-14 10:51:43

标签: forms symfony symfony-forms

我有一个这样的表格:

$formMapper
    ->add('formats', 'collection', array(
        'type'         => new FormatType(),
        'allow_add'    => true,
        'allow_delete' => true,
        'prototype' => true,
        'prototype_name' => 'remove'
    ))
    ->add('papers', 'collection', array(
        'type'         => new PaperType(),
        'allow_add'    => true,
        'allow_delete' => true,
        'prototype' => true,
        'prototype_name' => 'remove'
    ))
;

如您所见,我将prototype_name更改为remove

最初它看起来像这样: enter image description here

当我点击加号时,我得到了这个: enter image description here

如您所见,添加了remove文字。但也标签__ *。如何修复此标签__ *文本未添加或显示?

2 个答案:

答案 0 :(得分:0)

使用'label_attr' => ['style' => 'display: none']

$formMapper
    ->add('formats', 'collection', array(
        'type'         => new FormatType(),
        'allow_add'    => true,
        'allow_delete' => true,
        'prototype' => true,
        'label_attr' => ['style' => 'display: none']
    ))
    ->add('papers', 'collection', array(
        'type'         => new PaperType(),
        'allow_add'    => true,
        'allow_delete' => true,
        'prototype' => true,
        'label_attr' => ['style' => 'display: none']
    ))
;    

答案 1 :(得分:0)

->add('appointment', CollectionType::class,[
            'label' => false,
            'entry_type' => AppointmentType::class,
            'entry_options' => ['label' => false],
            'allow_add' => true,
            'allow_delete' => false,
            'prototype' => true,
        ])

这是我用于添加约会的集合,请参阅 entry_options