I use wtforms and I need to create something that will generate a form definition based on the information in the database; creating a dynamic form. I get an idea of ββwhat needs to be done, and I just got started. I can create forms and use them with wtforms / flask, but defining forms from data that will be slightly different from form to form currently exceeds my current skill level.
Has anyone done this and offered any input? Most likely a vague question, there is no valid code yet. I did not find examples, but this is impossible to do.
mass of variable data to be used in a form --> wtforms ---> form on webpage
EDIT:
So, for example, we can use polls. The overview consists of several SQLAlcehmy models. A survey is a model with any number of models of related questions (questions relate to surveys, and this is complicated, for example, by multiple choice questions). To simplify, use a simple json / dict pseudo-code for:
{survey:"Number One", questions:{ question:{type:truefalse, field:"Is this true or false"}, question:{type:truefalse, field:"Is this true or false"}, question:{type:text, field:"Place your X here"} } } {survey:"Number Two", questions:{ question:{type:text, field:"Answer the question"}, question:{type:truefalse, field:"Is this true or false"}, question:{type:text, field:"Place your email address here"} } }
Imagine instead several hundred different lengths with 5+ field types. How to use WTForms to manage forms for this, or do I even need to use wtforms? I can define static forms as needed, but not dynamically.
As an aside, I did something similar in rails with simpleform, but since I work in Python atm (on something else, I use the polling example as an example, but the question / field / answer theses on many types of input data that I needed).
So, yes, maybe I need to create some kind of factory, for this I will need some time, for example:
http://wtforms.simplecodes.com/docs/1.0.2/specific_problems.html
https://groups.google.com/forum/?fromgroups=#!topic/wtforms/cJl3aqzZieA