如果不存在,我尝试使用 select2 实体创建标签。当我尝试添加包含空格的标签时,我不能。例如:
- "Yupi yola" -->不起作用,因为标签包含空格,只得到第一个单词"Yupi"。
-
"测试"--->工作
-
"Test_test"--->工作
我在表单类型中添加了 Select2Entity
->add('groupe', Select2EntityType::class, [
'remote_route' => 'route',
'class' => Class::class,
'primary_key' => 'id',
'text_property' => 'name',
'minimum_input_length' => 2,
'page_limit' => 10,
'allow_clear' => true,
'delay' => 250,
'cache' => true,
'cache_timeout' => 60000, // if 'cache' is true
'language' => 'en',
'placeholder' => 'Select a group',
'allow_add' => array(
'enabled' => true,
'new_tag_text' => '',
'tokenSeparators'=> '[",", " "]'
),
'multiple' => false,
'attr' => ['style' => 'width:100%'],
'scroll' => true,
])
请帮助我。提前感谢。
不要使用
"tokenSeparators",而是使用"tag_separators"
'allow_add' => array(
'enabled' => true,
'new_tag_text' => '',
'new_tag_prefix' => '__',
'tag_separators'=> '[",", " "]'
)