django-autocomplete-light icon indicating copy to clipboard operation
django-autocomplete-light copied to clipboard

[question] - How to enable multiple select in dropdown for autocomplete_light.MultipleChoiceField

Open sushovan23 opened this issue 9 years ago • 7 comments

Hi, I'm using autocomplete_light.MultipleChoiceField for multiple choice field. I'm able to get dropdown populated with values and for each value i need to enter the text and select values. If I need to select 10 values from the drop down i need to type 10 times. Is there a way to enable/allow multiple select from download so that user needn't type in the regex in search field 10 times?

class HostGroupModelForm( autocomplete_light.ModelForm ): hosts=autocomplete_light.MultipleChoiceField('HostAutocomplete')

class HostAutocomplete( autocomplete_light.AutocompleteModelBase ): search_fields = [ 'hostname' ] limit_choices = 75 choices = Host.objects.all()

sushovan23 avatar Feb 04 '16 22:02 sushovan23

In DAL v3, you could probably do that with select:closing DOM event.

jpic avatar Feb 05 '16 00:02 jpic

How can it be achieved in 2.2.6?

sushovan23 avatar Feb 05 '16 14:02 sushovan23

It would be good if user can select multiple items from dropdown by pressing control key. Is there a way to achieve this?

sushovan23 avatar Feb 05 '16 14:02 sushovan23

There's always a way ;) Just override the right function in the script.

jpic avatar Feb 05 '16 17:02 jpic

Is there any update of this? In 3.5.1

brenramz avatar Jul 17 '20 17:07 brenramz

Example:

class XXXForm(ModelForm):

  xxxxuser = MultipleChoiceField(
    choices=[],
    widget= autocomplete.ListSelect2(
      url='user_autocomplete', 
      attrs={
        'data-html': True , 
        'data-placeholder': 'Find user',
        'multiple': True
      }
    )
  )

mpochron avatar Dec 08 '20 14:12 mpochron

Is there a way to select one element multiple times from dropdown?

hammadarshad1 avatar Apr 12 '23 12:04 hammadarshad1