简体   繁体   English

Flask_WTF:PasswordField禁用自动完成

[英]Flask_WTF: PasswordField disable autocomplete

How can I add a custom parameter to a field in a flask_wtf form-field. 如何将自定义参数添加到flask_wtf表单字段中的字段。 One of my requirements is to add the autocomplete="off" to all password fields, but I can't seem to find out how I can add this parameter to a password field in flast_wtf generated form. 我的要求之一是将autocomplete="off"添加到所有密码字段,但是我似乎无法找出如何将此参数添加到flast_wtf生成形式的密码字段中。

You can pass HTML attributes directly to form fields by name, with the exception of class , which uses class_ to avoid the reserved word. 您可以按名称直接将HTML属性传递给表单字段,但class除外,它使用class_避免保留字。

{{ form.password(autocomplete="off") }}

If you use a macro like this to render your fields, you can still pass it through **kwargs : 如果您使用这样的来渲染字段,则仍然可以通过**kwargs传递它:

{{ render_field(form.password, autocomplete="off") }}

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

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