我使用Flask-WFT documentation page上呈现的render_field宏在不同的模板中以长格式呈现字段。在
字段定义如下
year_built = IntegerField(label='Year Built',
description='Year built, not the year of a major renovation.',
validators=[validators.NumberRange(
min=1700,
max=2012,
message="Between %(min)s and %(max)s")])
宏看起来像这样。。。在
^{pr2}$在表单本身中,各个字段使用。。。在
{{ render_field(form.year_built, class="input text")}}
我搞不懂的是如何在创建HTML字段field(**kwargs)
的宏部分中使用field对象中的描述。我知道我可以将关键字传递给render_field函数,但我要处理的窗体中有100多个字段,并在表单.py然后在模板.html好像是不必要的重复。我真的很想使用宏来显示一个描述作为标题,如果它没有,或者只显示没有标题的字段。在
有没有办法在field()函数运行之前向kwargs
添加新条目?在
所以这比我想象的要容易得多。。。在
相关问题 更多 >
编程相关推荐