Reputation: 910
I am trying to make a multiselecte dropdown field with clear button in flask like this.
I have tried this but not working the way I want
type = SelectMultipleField("Type",choices=[("None", "None"), ("one", "one"), ("two", "two"), ("three", "three")], default=[('None', 'None')]
but I am getting like this, getting all choices at once without dropdown option
Upvotes: 0
Views: 73
Reputation: 68
I also faced the same issue once, Better send the list of choices in your templete and run loop in option tag like this
<option value="None" selected>None</option>
{% for row in vin %}
<option value="{{row}}">{{row}}</option>
{% endfor %}
Upvotes: 1
Reputation: 2149
The problem in your code comes from the way you have defined the choices. The SelectMultipleField
field requires the choices to be defined as a list of tuples. Like this :
typess = SelectMultipleField("Type", choices=[("None", "None"), ("one", "one"), ("two", "two"), ("three", "three")], default=[('None', 'None')])
Upvotes: 0