<table>
{{=form.custom.begin}}
<thead>
<tr>
{{ #loop over form field labels... something like:
for field in form.fields: }}
<th>{{=field.label}}</th>
{{ pass }}
</tr>
</thead>
<tbody>
<tr>
{{for field in form.fields: }}
<td>{{ =form.custom.widget[field] }}</td>
{{ # or directly access it without a loop with form.custom.widget.SomeFieldA }}
{{ pass }}
</tr>
</tbody>
{{=form.custom.submit}}
{{=form.custom.end}}
</table>
1 回答
你都尝试了些什么?听起来你想要一个布尔数据模型:
(在models / ??? . py中 - 确保它在db.py之后执行并且你已经定义了一个DB)
你可能需要实现一个自定义表单来获得你想要的布局,因为我无法想到一个开箱即用的方法 .
阅读custom forms here .
你需要从以下内容开始:
请注意,我没有测试任何此代码,我可能正在访问表单字段并且标签不正确 . 如果需要预先填充表单,请在控制器中执行此操作 . 上面的自定义表单链接也讨论了预填充 .