WTForms support for input readonly attribute?

前端 未结 4 1746
伪装坚强ぢ
伪装坚强ぢ 2021-02-04 02:14

Here they say it\'s not supported out of the box.

Do you know a way to make HTML input form fields use the \'readonly\' attribute with WTForms?

4条回答
  •  无人共我
    2021-02-04 02:31

    The solution is using render_kw in form field declaration.

    my_field = fields.StringField('Label', render_kw={'readonly': True})
    

提交回复
热议问题