简体   繁体   English

WTForms如何使用描述参数

[英]WTForms how to use description paramter

I have some simple boolean field and I want to add a short description.我有一些简单的 boolean 字段,我想添加一个简短的描述。 I specified a description parameter but it seems like no effecr.我指定了一个description参数,但似乎没有效果。 How it suppose to work at all?它应该如何工作?

from wtforms import BooleanField, Form


class AdminUsersForm(Form):
    foo = BooleanField(label='foo', default=True, description='foo')
<form method="GET">
    <div>
        {{ form.foo.label }}
        {{ form.foo(placeholder=checkbox.description)}}
        # No description impact at all, even tooltip.
    </div>
</form>

I found this answer but not sure that it's my case我找到了这个答案,但不确定这是我的情况

You almost have it.你几乎拥有它。 Try changing your 'placeholder' to display the text that you have defined:尝试更改您的“占位符”以显示您定义的文本:

{{ form.foo(placeholder=form.foo.description)}}

You access this the same way as the form.label , simply by calling the parameter of the field of the form.您访问它的方式与form.label相同,只需调用表单字段的参数即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM