我试图在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)
;