我有一个很长的表单(100多个字段)。它由各种字段类型组成,包括
IntegerRangeField
,
FormField
FieldList
还有更多。
class SubForm(Form):
first_name=TextField('First')
age=IntegerRangeField('Age')
class MainForm(Form):
height=IntegerRangeField('Height')
weight=IntegerRangeField('Weight')
friend_list=FieldList(FormField(SubForm),'Friends')
这个
IntegerRangeFields
默认情况下不显示滑块值,因此我使用javascript函数
JSfunction
使用宏渲染所有内容:
{% for field in form if field.type not in ["HiddenField","CSRFTokenField"] %}
{% if field.type in ["IntegerRangeField"] %}
{{field.label}}
{{field(min=0, max=100, oninput="JSfunction(this)")}}
<output><script> document.write() </script></output>
{% else %}
{{field.label}}
{{field}}
{% endif %}
{% endfor %}
积分域
福尔菲尔德
在
这样我就可以申请了
JSfunction
FormFields
在
字段列表
不显示滑块值。
编辑:
即
height ----------|| 100
FieldList中的IntegerRangeFields没有应用JSF函数,因此滑块旁边没有整数值:
即
age ||----------
我很难在字段列表的FormFields中遍历IntegralErrangeFields。