I'm trying to re-use my flask-security login form in a couple of different places, so I defined it as a macro like this:
{% macro loginForm(inForm) %}
<form class="form-signin" action="{{ url_for_security('login') }}" method="POST" name="loginForm">
{{ inForm.hidden_tag() }}
{{ renderFieldWithErrors(inForm.email, class="form-control top", placeholder="Login ID", required=True, autofocus=True) }}
{{ renderFieldWithErrors(inForm.password, class="form-control bottom", placeholder="Password", required=True) }}
<div class="checkbox">
<label>
{{ inForm.remember() }} Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
<p style="margin-top: 1em;"><a href="{{ url_for_security('forgot_password') }}">Trouble Logging In?</a></p>
</form>
{% endmacro %}
Unfortunately, url_for_security
is undefined in this context. If I change it to url_for
, it works fine, but then it says hidden_tag
doesn't exist. It seems the macro doesn't have the same set of things defined as the calling context. Can this be corrected? Thanks.