{% import 'macros/messages.html' as messages_macros with context -%}
{% import 'macros/form.html' as form_macros with context -%}

{# In 0.6 update(configuration) - title must be in configuration dictionary #}
{% macro update(title, configuration) -%}
    <h1>{{ title }}</h1>
    {{ messages_macros.messages() }}
    <form class="form-horizontal" method="post" action="{{ configuration['url'] }}">
        {{ form_macros.generate_elements(configuration['form'], configuration['display_blocks']) }}
        <div class="form-actions">
            <div class="btn-group pull-left">
                {% if configuration['submit'] %}
                {% for action_element in configuration['submit_actions'] %}
                {{ actions_macros.action(action_element=action_element) }}
                {% endfor %}
                {% else %}
                <input class="btn btn-primary" type="submit" value="Save" />
                {# in 0.6 default _save_and_add will be removed #}
                <input class="btn btn-primary" type="submit" value="Save and Add" name="_save_and_add" />
                {% endif %}
            </div>
            <div class="btn-group pull-right">
                {% for action_element in configuration['actions'] %}
                {{ actions_macros.action(action_element=action_element) }}
                {% endfor %}
            </div>
        </div>
    </form>
{%- endmacro %}
