Insert HTML tag into Flask WTForms field
I am using Flask with Jinja2 / WTForms to create a login page and I want to customize the Remember Me checkbox. For this, I would like to add an empty tag <span>
to the form label field. Here is the Jinja2 code in the HTML file:
{{ login_user_form.remember|safe }} {{ login_user_form.remember.label }}
which generates the following HTML:
<input id="remember" name="remember" type="checkbox" value="y"> <label for="remember">Remember Me</label>
However, the following HTML is what I'll eventually like - notice the tag <span>
embedded within the label.
<input id="remember" name="remember" type="checkbox" value="y"> <label for="remember"><span></span>Remember Me</label>
+1
source to share