0

How do I override the default registration form in Flask-Security is to remove all label attributes. In the documentation there is a section of the customizing view, but in the example is to add the fields to the form, and I need to change the default.

user3419632
  • 33
  • 1
  • 8

1 Answers1

2

I did this by editing the _macros.html file in the flask-security library, by default it looks like this:

{% macro render_field_with_errors(field) %}
  <p>
    {{ field.label }} {{ field(**kwargs)|safe }}
    {% if field.errors %}
      <ul>
      {% for error in field.errors %}
        <li>{{ error }}</li>
      {% endfor %}
      </ul>
    {% endif %}
  </p>
{% endmacro %}

source: https://github.com/mattupstate/flask-security/blob/c7d0ea9cceb5d2fab7b98a21579da86aa2a3c20b/flask_security/templates/security/_macros.html

To remove labels, remove the label expansion:

{% macro render_field_with_errors(field) %}
  <p>
    {{ field(**kwargs)|safe }}
    {% if field.errors %}
      <ul>
      {% for error in field.errors %}
        <li>{{ error }}</li>
      {% endfor %}
      </ul>
    {% endif %}
  </p>
{% endmacro %}

The file for me (using venv) was in this path, you might want to find it with find or otherwise: ./venv/lib/python3.4/site-packages/flask_security/templates/security/_macros.html

DevOops
  • 943
  • 2
  • 10
  • 21