我目前正在使用select2 v4,因为现在需要选择而不是输入我在验证选项时遇到问题,因为我通过ajax加载这些选项。
我安装了tetranz / select2entity-bundle(https://github.com/tetranz/select2entity-bundle)。我完全按照说明操作,我现在在安装后收到此错误:
The option "multiple" does not exist. Known options are: "action", "attr",
"auto_initialize", "block_name", "by_reference", "cascade_validation",
"compound", "constraints", "csrf_field_name", "csrf_message",
"csrf_protection", "csrf_provider", "csrf_token_id", "csrf_token_manager",
"data", "data_class", "disabled", "empty_data", "error_bubbling",
"error_mapping", "extra_fields_message", "inherit_data", "intention",
"invalid_message", "invalid_message_parameters", "label", "label_attr",
"mapped", "max_length", "method", "pattern", "post_max_size_message",
"property_path", "read_only", "required", "translation_domain", "trim",
"validation_groups", "virtual"
500 Internal Server Error - InvalidOptionsException
除了安装我的表单构建器 - >添加如下所示:
->add('receiver_physician', 'tetranz_select2entity', array(
'multiple' => false,
'remote_route' => 'ajax_physician_search_by_term',
'class' => '\HospitalBundle\Entity\Physician',
'text_property' => 'name',
'minimum_input_length' => 2,
'page_limit' => 10,
'placeholder' => 'Select a Physician',
))
其他人有这个问题吗?
答案 0 :(得分:0)
与tetranz_select2entity相关联的类具有configureOptions()方法。它是在Symfony 2.7中引入的。以前,该方法称为setDefaultOptions()。
作为止损,我将以下内容添加到Select2EntityType:
/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$this->configureOptions($resolver);
}
("使用"声明也需要。作者要遵循的贡献。)