Skip to content

Docs about SelectField is misleading #875

@Tikrong

Description

@Tikrong

The docs says this about SelectField:

Note that the choices keyword is only evaluated once, so if you want to make a dynamic drop-down list, you’ll want to assign the choices list to the field after instantiation.

https://wtforms.readthedocs.io/en/3.2.x/fields/#wtforms.fields.SelectField

But it seems that in current version (3.2) the field is processed differently and each time you create a form during a request, it runs the init() method of the SelectField class, and if choices is a callable, it will be called each time you create a form to populate field choices. Therefore I suggest to correct the docs, if it is an expected behaviour, because now they describe different one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationRelated to the documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions