{% import 'macros/form.html' as form %}
{% block error_summary %} {{ form.errors(error_summary) }} {% endblock %} {% block basic_fields %} {% set attrs = {'data-module': 'slug-preview-target'} %} {{ form.input('title', label=_('Name'), id='field-name', placeholder=_('My Group'), value=data.title, error=errors.title, classes=['control-full'], attrs=attrs) }} {# Perhaps these should be moved into the controller? #} {% set prefix = h.url_for(controller='group', action='read', id='') %} {% set domain = h.url_for(controller='group', action='read', id='', qualified=true) %} {% set domain = domain|replace("http://", "")|replace("https://", "") %} {% set attrs = {'data-module': 'slug-preview-slug', 'data-module-prefix': domain, 'data-module-placeholder': ''} %} {{ form.prepend('name', label=_('URL'), prepend=prefix, id='field-url', placeholder=_('my-group'), value=data.name, error=errors.name, attrs=attrs, is_required=true) }} {{ form.markdown('description', label=_('Description'), id='field-description', placeholder=_('A little information about my group...'), value=data.description, error=errors.description) }} {% set is_upload = data.image_url and not data.image_url.startswith('http') %} {% set is_url = data.image_url and data.image_url.startswith('http') %} {{ form.image_upload(data, errors, is_upload_enabled=h.uploads_enabled(), is_url=is_url, is_upload=is_upload) }} {% endblock %} {% block custom_fields %} {% for extra in data.extras %} {% set prefix = 'extras__%d__' % loop.index0 %} {{ form.custom( names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'), id='field-extras-%d' % loop.index, label=_('Custom Field'), values=(extra.key, extra.value, extra.deleted), error=errors[prefix ~ 'key'] or errors[prefix ~ 'value'] ) }} {% endfor %} {# Add a max if 3 empty columns #} {% for extra in range(data.extras|count, 3) %} {% set index = (loop.index0 + data.extras|count) %} {% set prefix = 'extras__%d__' % index %} {{ form.custom( names=(prefix ~ 'key', prefix ~ 'value', prefix ~ 'deleted'), id='field-extras-%d' % index, label=_('Custom Field'), values=(extra.key, extra.value, extra.deleted), error=errors[prefix ~ 'key'] or errors[prefix ~ 'value'] ) }} {% endfor %} {% endblock %} {{ form.required_message() }}
{% block delete_button %} {% if h.check_access('group_delete', {'id': data.id}) %} {% block delete_button_text %}{{ _('Delete') }}{% endblock %} {% endif %} {% endblock %}