从wtforms获取表单数据并在其上写入条件
我试图在wtfforms做一个调查,但我试图让一个特定的问题出现 基于用户响应。获取用户选择的信息的语法是什么 调查中 表格代码从wtforms获取表单数据并在其上写入条件,forms,dynamic,options,wtforms,Forms,Dynamic,Options,Wtforms,我试图在wtfforms做一个调查,但我试图让一个特定的问题出现 基于用户响应。获取用户选择的信息的语法是什么 调查中 表格代码 from wtforms import Form, SelectField, StringField, IntegerField, SelectMultipleField, SubmitField, BooleanField, validators class PhoneSurvey(Form): terminal_number = IntegerFiel
from wtforms import Form, SelectField, StringField, IntegerField, SelectMultipleField, SubmitField, BooleanField, validators
class PhoneSurvey(Form):
terminal_number = IntegerField('Terminal number')
was_this_a_pandemic_related_call = SelectField('Was this a Pandemic related call', choices=[('yes', 'Yes'),
('no', 'No')])
what_was_the_call = SelectField('What category was this call', choices=[('get_food', 'NYC Get Food'),
('covid_test', 'COVID-19 Testing'),
('remote_learning', 'Remote Learning'),
('other', 'Other')])
pandemic_related_text = StringField('Briefly describe this pandemic related call?')
non_pandemic_related_text = StringField('Briefly describe this non pandemic related call?')
able_to_resolve_other_text = StringField('What happened to this call?')
was_the_inquiry_resolved = SelectField('Was the inquiry resolved', choices=[('yes', 'Yes'), ('no', 'No'),
('other', 'Other')])
inquiry_resolution_other = StringField('What happened to this call?')
submit = SubmitField('Submit')
HTML
{{form.non_-employment_-related_-text.label}:{{form.non_-employment_-related_-text(class=“css_-class”)}
试图弄清楚他们的选择是肯定的还是否定的,然后从那里开始
显示问题的其余部分
像
{{form.non_-popularity_-related_-text(class=“css_-class”)}
{%if form.non_-related_-text.no}
{%else%}
{{form.able_to_resolve_text.label}:{{form.able_to_resolve_other_text(class=“css_class”)}
{{form.was\u theu inquiry\u resolved.label}:{{form.was\u theu inquiry\u resolved(class=“select”)}
{{form.inquiry\u resolution\u other.label}:{{form.inquiry\u resolution\u other(class=“css\u class”)}
{%endif%}
{{form.submit(class=“button is primary is rounded”)}
<div class="form-field space"> {{ form.non_pandemic_related_text.label}}: {{ form.non_pandemic_related_text(class="css_class") }}</div>
{{ form.non_pandemic_related_text(class="css_class") }
{%if form.non_pandemic_related_text.no}
{% else %}
<div class="form-field space"> {{ form.able_to_resolve_other_text.label}}: {{ form.able_to_resolve_other_text(class="css_class") }}</div>
<div class="form-field space"> {{ form.was_the_inquiry_resolved.label}}: {{ form.was_the_inquiry_resolved(class="select") }}</div>
<div class="form-field space"> {{ form.inquiry_resolution_other.label}}: {{ form.inquiry_resolution_other(class="css_class") }}</div>
{%endif%}
<div class="center space">
{{ form.submit(class="button is-primary is-rounded") }}
</div>