Reputation: 784
I am using flask wtforms multiple select that is showing 4 options by default and as I have the sth like 20 options in total, scrolling isn't really convenient. Is there a way to make the select higher to show more than 4 options at a time?
I tried to use rows attribute, but probably I did it wrong as it is not working(I don't know too much about HTML)
Part of my code related to this:
class PositionForm(FlaskForm):
position = SelectMultipleField(u'Choose position:')
...
@app.route('/custom', methods=['POST', 'GET'])
def custom():
position_form.position.choices = []
for position in positions_db:
positions.append(position.name)
position_form.position.choices.append((position.name, position.name))
...
return render_template('table.html',... , position_form=position_form)
HTML code:
<form action="/custom" method="post" style="margin: 2px 10px 2px 10px; font-weight: bold;">
<div>{{ position_form.position.label }}<br>
{{ position_form.position(rows=6, multiple=True) }}</div>
</form>
Upvotes: 0
Views: 985
Reputation: 26
You can just add size attribute when calling the form, example:
<div>{{ position_form.position.label }}<br>
{{ position_form.position(rows=6, multiple=True, size=15) }}</div>
Upvotes: 1
Reputation: 150
You can arrange in HTML your choices in a 3 cols x 7 rows table. When you use scripting in flask inside HTML you could use i,j as iterators when filling the table with your choices.
More on tables
Upvotes: 0