如何使用SonataAdminBundle的ChoiceFieldMaskType作为复选框?

时间:2019-08-16 09:17:13

标签: symfony4 sonata-admin sonata

我试图在SonataAdminBundle的FormMapper中使用一个复选框,并且取决于该复选框是否被选中,应该显示或隐藏另一个输入字段。这就是为according to the docs创建的ChoiceFieldMaskType的内容,但是我不知道如何将其呈现为checkbox,它始终是select形式。

有人可以帮助我吗? 谢谢!

我尝试过的事情:

$formMapper
    ->add('isMyCheckboxRequired', ChoiceFieldMaskType::class, [
        'choices' => [
            false => false,
            true => true,
        ],
        'map' => [
            false => [],
            true => ['showOtherInputFieldWithThisName'],
        ],
        'required' => true
    ])
    ->add('pathPrefix', TextType::class)
;

0 个答案:

没有答案