【发布时间】:2019-03-05 04:50:17
【问题描述】:
我正在寻找一种将占位符添加到集合字段原型的方法。添加属性“占位符”不会产生任何效果。 我尝试使用prototype_data并在twig中用占位符替换值属性,但如果字段类型是数字,则会引发错误,并且传递的文本值不能转换为数字。
$builder->add('fees', CollectionType::class, [
'allow_add' => true,
'allow_delete' => true,
'delete_empty' => true,
'entry_type' => TextType::class,
'prototype' => true,
'attr' => [
'placeholder' => 'Fee Type',
],
])
【问题讨论】:
-
将
attr选项移动到entry_options。
标签: forms symfony collections twig placeholder