{% 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 }}

You may 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='sm-margin-bottom') %} {% endcall %} {% call f.form_group(form.currency, css_class='sm-margin-bottom') %} {% endcall %} {% call f.form_group(form.duration, css_class='sm-margin-bottom') %} {% endcall %}
{% call f.form_group(form.duration_in_months, css_class='sm-margin-bottom') %} {% endcall %}
{% call f.form_group(form.max_redemptions, css_class='sm-margin-bottom') %} {% endcall %}
{% call f.form_group(form.redeem_by) %} {% endcall %}

{% endcall %}