Populate WTForm MultiCheckboxField with Flask-Principal Roles
data
for a multi-select field is a list of form_data
after it has been coerced by your coerce
callable - so what you provide needs to match what's available as the first entry in each tuple you provide to choices
- in this case, an integer. That said, if you change your code to:
editform.roles.data = [role.id for role in user.roles]
you should see all the appropriate checkboxes checked.