Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make my flask wtforms SelectField look like a dropdown?

I've created a SelectField like so:

class Inputs(Form):
    myChoices = #number of choices
    myField = SelectField(u'Field name', choices = myChoices, validators = [Required()])

The problem is that when it renders in my template:

<form action="" method="post" name="Inputs">
    {{form.hidden_tag()}}
    <p>
        {{form.myField(size=80)}}
    </p>
</form>

It looks like a long select box with all the values already shown, rather than a drop-down menu. How do I change this formatting? Thanks!

like image 798
YPCrumble Avatar asked Feb 16 '14 14:02

YPCrumble


1 Answers

The problem was the (size=80) in my html - I deleted this and it works fine. I thought this was a way to limit the size of the dropdown similar to TextField form field, but obviously not!

like image 120
YPCrumble Avatar answered Oct 20 '22 11:10

YPCrumble