Issue
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>
Solution
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>
Answered By - Yago de Carvalho Souto
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.