2

I'm interesting in how do I get input field working as default flask-admin multi input field: enter image description here What widget/field should I use?

It seems like i need to use Select2TagsField, but how do i fill it with data? It just show me 'No matches found':

class CustomModelView(ModelView):
    form_columns = ('things_list',)
    form_extra_fields = {
        'things_list': Select2TagsField(
            'Things',
            coerce=int
        ),
    }

enter image description here

1 Answer 1

6

Example codes of flask + wtforms + select2. Remember to override SelectMultipleField to prevent "not a valid choice" error.

2
  • many thanks for native solution (without flask-admin's Select2TagsField field ), but i'm still interesting in how to get Select2TagsField working. Anyway I've found, that I might use Select2Field (which is inherited from WTForms' SelectField), passed multiple=True to it.
    – aryndin
    May 29, 2016 at 8:10
  • Many thanks for your answer! Although it does not fit the question a bit, i've managed to apply it in my project. Only one remark - we doesn't need to override pre_validate function to pass to prevent not a valid choice error - just pass coerce=int to field constructor.
    – aryndin
    Jun 7, 2016 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.