通常应该有两个输出,两个输出都用分类法ID填充-某种程度上存在一个会导致错误的“占位符”元素。我真的不明白它是从哪里来的,有什么想法吗?我想最好的办法是在屏幕截图中显示它(另外,一部分作为代码显示)。输出是带有Twig的dump()函数的。
在dump()中生成了symfony表单元素ID(3个表单元素,预期2个):
"id" => "Filter_filter_1462_boolcollectionradiomodell_placeholder"
"id" => "Filter_filter_1462_boolcollectionradiomodell_8368"
"id" => "Filter_filter_1462_boolcollectionradiomodell_33696"
此处是带有ID和一些其他信息的屏幕快照,例如symfony表单元素中的空值:
该值为空,其他的(预期的)则填充有分类ID。
这是symfony表单的一部分:
$builder->add(
'filter_' . $filter->getId() . '_boolcollectionradio',
EntityType::class,
array(
'class' => AutoTaxonomie::class,
'choices' => $choices,
'expanded' => true,
'multiple' => false,
'required' => false,
'label' => ('detail' == $this->entry) ? $tmp : false,
'attr' => array('data-taxid' => $filter->getId(), 'class' => 'form-group'),
'choice_label' => function (AutoTaxonomie $taxonomie) {
$view_data = array(
'title' => $taxonomie->getTitle(),
'beschreibung' => $taxonomie->getDescription(),
);
return json_encode($view_data);
},
)
);
symfony:3.4 树枝:2.5
任何建议都将受到高度赞赏,祝您愉快!
答案 0 :(得分:1)
默认显示EntityTypeField
的占位符元素,即documented。
尝试将其设置为false以防止其显示:
$builder->add('filter_', EntityType::class, array(
'placeholder' => false,
));