python - Cannot override default BooleanField with FieldList FormField on wtforms -
i using wtforms , flask , running issues overriding default value boolean field. field subform shown below. not entirely sure issue is. when try , create subform value false , render subform default overrode when sub form not.
class user(db.model): __tablename__ = 'users' include = db.column(db.boolean) class subform(form): include = booleanfield('include', default=true) class parentform(form): sub = fieldlist(formfield(subform)) @app.route('/') def index(): if form.validate_on_submit(): pass users = user.query.all() fields = [subform(include=user.include) user in users] form = parentform(sub=fields) return render_template('index.html', form=form)
index.html
{% block content %} <div> <form action="" method="post" class="form" role="form"> {% form.csrf_token %} <ul> {% field in form.sub %} {% field.form.csrf_token %} <li>{% field.form.include %}</li> {% endfor %} </ul> </form> </div> {% endblock %}
edit
fieldlist not booleanfields apparently. in instance using formfield. http://wtforms.readthedocs.io/en/latest/fields.html#wtforms.fields.fieldlist
Comments
Post a Comment