Trying to fill out a Wtform form Wtform , with the data pulled out the mongo db database and then provided it with jinja / flask to create an editable pre-filled form for the REST system I am creating.
My form structure:
class ProjectForm(Form): name = TextField("Name of Project") workflow =FieldList(TextField(""), min_entries=5) class InstituteForm(Form): institue_name = TextField("Name of Institue") email = FieldList(TextField(""), min_entries=3) project_name = FormField(ProjectForm) submit = SubmitField("Send")`
I can pre-populate the list of fields using this syntax:
form = InstituteForm(institue_name="cambridge", email=[" email@gmail ", " email@gmail "])
however, I cannot understand the syntax for pre-populating a FormField containing a form object.
First I create a project form:
p = ProjectForm(name=" test", workflow=["adadadad", "adasdasd", "adasdadas"])
& now I'm trying to add it to the InstituteForm form.
I tried:
form = InstituteForm(institue_name=store_i, project_name=p, email=store_email)
for which I get the html output:
Loaded example output [ http://tinypic.com/r/jpfz9l/5] , there are not enough points to place the image for.
and I tried syntax like:
form = InstituteForm(institue_name=store_i, project_name.name=p, email=store_email)
and
form = InstituteForm(institue_name=store_i, project_name=p.name, email=store_email)
and even
form = InstituteForm(institue_name=store_i, project_name=ProjectForm(name="this is a test"), email=store_email)
Was there a search and found another thread (no answer) to a similar question:
Using FieldList and FormField