flask-wtforms field required

前端 未结 2 567
猫巷女王i
猫巷女王i 2020-12-21 01:18

how i can add tag required on this flask code :

{{ form.youtube_href(type=\'url\', class=\'form-control\') }}

actual output is :

         


        
2条回答
  •  眼角桃花
    2020-12-21 01:59

    To those who simply want to add the required attribute to their html input, this can be accomplished by following the comment mentioned by Raja Simon above. Simply call your field name in your template with required='required' Example:

    ... {{myform.my_name_field(required='required')}} {{myform.my_email_field(required='required')}} ...

    The Above code will result in fields like so:

    
    

提交回复
热议问题