简体   繁体   中英

symfony2 tetranz select2entity-bundle

I'm currently using select2 v4, since this now requires a select and not an input i'm having issues validating options as i'm loading these via ajax.

I installed the tetranz/select2entity-bundle ( https://github.com/tetranz/select2entity-bundle ). I followed the instructions thouroughly and i'm now receiving this error after install:

 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 

Additionally to the installation my form builder ->add looks like this:

       ->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',
       ))

Anyone else had this issue?

The class associated with tetranz_select2entity has a configureOptions() method. It was introduced in Symfony 2.7. Previously, the method was called setDefaultOptions().

As a stop gap, I added the following to Select2EntityType:

/**
 * @param OptionsResolverInterface $resolver
 */
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $this->configureOptions($resolver);
}

( "use" statement also needed. Contribution to authors to follow. )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM