{% import 'macros/form.html' as f with context %} {% if request.endpoint.endswith('new') %} {% set endpoint = 'admin.coupons_new' %} {% set form_kwargs = {} %} {% set legend = 'Add a new coupon' %} {% set button = 'Add' %} {% else %} {% set endpoint = 'admin.coupons_edit' %} {% set form_kwargs = {'id': coupon.id} %} {% set legend = 'Update this coupon' %} {% set button = 'Save' %} {% endif %}
{% call f.form_tag(endpoint, **form_kwargs) %}

{{ legend }}
Pick either a percent or amount off

{% call f.form_group(form.percent_off) %}{% endcall %}
{% call f.form_group(form.amount_off) %}{% endcall %}

{% call f.form_group(form.code, css_class='text-uppercase') %}{% endcall %} {% call f.form_group(form.currency) %}{% endcall %} {% call f.form_group(form.duration) %}{% endcall %}
{% call f.form_group(form.duration_in_months) %} {% endcall %}
{% call f.form_group(form.max_redemptions) %}{% endcall %} {{ f.field_label(form.redeem_by) }}
{{ f.field(form.redeem_by) }}
{{ f.field_errors(form.redeem_by) }}
{% endcall %}