在气球帮助中,我想为每个选项设置一个标题属性,这样悬停光标就会将该属性显示为“WTForms SelectField”。如下所示:
<select name='station'>
<option title='Thule'>TH</option>
<option title='Diego Garcia'>DG</option>
...
</select>我看到我可以遍历SelectField以获得每个选项的fields.core._Option实例,我可以将标题文本存储在每个选项的.description属性中。如何修改HTML呈现以使用title值作为.description属性?
发布于 2018-06-14 02:58:38
显示更多代码以提供帮助,但请使用以下示例
fieldstation = wtforms.SelectField('station', choices=[("TH", "Thule"), ("DG", "Diego Garcia")])或者类似的东西
fieldstation = wtforms.SelectField(model.Ferris.station._verbose_name, choices=[(t, t.title()) for t in model.Ferris.station._choices])https://stackoverflow.com/questions/29688673
复制相似问题