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

YPCrumble picture YPCrumble · Feb 16, 2014 · Viewed 19.9k times · Source

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!

Answer

YPCrumble picture YPCrumble · Feb 16, 2014

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!