{% set lastevent = 0 %}
{% if data.event %}
{# Case we have events. Display them + an empty field with '+' button #}
{% for ev in data.event %}
{% set index = loop.index %}
{% if ev['type'] and (ev['who']|length>0 or ev['when']|length>0 or ev['descr']|length>0) %}
{% set lastevent = loop.index %}
{% if errors and errors.event and errors.event[index-1] %}
{% if errors.event[index-1]['type'] %}
{{ errors.event[index-1]['type']|join('. ') }}
{% endif %}
{% if errors.event[index-1]['who'] %}
{{ errors.event[index-1]['who']|join('. ') }}
{% endif %}
{% if errors.event[index-1]['when'] %}
{{ errors.event[index-1]['when']|join('. ') }}
{% endif %}
{% if errors.event[index-1]['descr'] %}
{{ errors.event[index-1]['descr']|join('. ') }}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% set lastevent = data.event|length + 1 %}
{% set index = lastevent %}
{{ kata_form.plusbutton(onclick="$(\'#evbtn__" ~ index ~ "__value_id\').change();") }}
{{ kata_form.tooltip(tooltip=_('Describe the lifecycle of your data by adding important events related to the data. A single event consists of four fields: event, by whom, when and description. Fill all four fields when adding an event.
You can add more events by first adding a new set of fields by clicking the \'+\' button.
To remove an event, delete its contents from the three text fields.')) }}
{% else %}
{# Case no events, that is a new blank form #}
{% set index = 1 %}
{{ kata_form.plusbutton(onclick="$(\'#evbtn__" ~ index ~ "__value_id\').change();") }}
{{ kata_form.tooltip(tooltip=_('Describe the lifecycle of your data by adding important events related to the data. A single event consists of four fields: event, by whom, when and description. Fill all four fields when adding an event.
You can add more events by first adding a new set of fields by clicking the \'+\' button.
To remove an event, delete its contents from the three text fields.')) }}