如何解决从wtforms获取表单数据并在上面写条件
我正在尝试对wtfforms进行调查,但是我想让某个问题出现 根据用户的响应。获取用户选择信息的语法是什么 在调查中
表单代码
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','No'),'Other')])
inquiry_resolution_other = StringField('What happened to this call?')
submit = SubmitField('Submit')
HTML
<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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。