{% use 'bootstrap_3_layout.html.twig' %} {# CONDITIONAL VISIBILITY #} {# these blocks are copied from https://github.com/symfony/twig-bridge/blob/master/Resources/views/Form/bootstrap_3_layout.html.twig with added conditional visibility #} {% block form_row -%}
{{- form_label(form) -}} {{- form_widget(form) -}} {{- form_errors(form) -}}
{%- endblock form_row %} {% block checkbox_row -%}
{{- form_widget(form) -}} {{- form_errors(form) -}}
{%- endblock checkbox_row %} {% block radio_row -%}
{{- form_widget(form) -}} {{- form_errors(form) -}}
{%- endblock radio_row %} {# END CONDITIONAL VISIBILITY #} {# error styling #} {% block form_errors -%} {% set isRoot = form.parent is empty %} {% if not valid -%} {% if not isRoot %} {% else %}
{% endif %} {% if not isRoot %} {% else %}
{% endif %} {%- endif %} {%- endblock %} {# hacky divider type, only for use with bootstrap_3_layout, other layouts are untested #} {% block panel_divider_row -%} {%- endblock %} {# translation forms #} {% block translation_form_widget -%} {# the form #}
{# Items #}

{{ 'admin.translation-form.main'|trans({}, translation_domain) }} 

{% for index, obj in form %} {% set delete_key = form.vars.id|replace({'form_': 'delete_'}) ~ "_" ~ index %}
{% if obj.vars.compound %} {{ form_widget(obj) }} {% else %} {% for child in obj.children %} {{ form_row(child) }} {% else %} {{ form_widget(obj) }} {% endfor %} {% endif %}
{% if index == 0 %}
{# end first column #}
{% endif %} {% endfor %}
{# end first item or tab-content #}
{# end col-sm-6 #}
{# end js-translation-form #} {%- endblock %} {# Nested forms #} {% block collection_widget -%} {% include 'BazookasAdminBundle:Form/Partials:_nested_form.html.twig' with { sortable: false, inline_elements: form.vars.inline_elements, allow_add: form.vars.allow_add, allow_delete: form.vars.allow_delete, min: 0, max: 0, prototype_name: form.vars.prototype_name is defined ? form.vars.prototype_name : '__name__', } %} {%- endblock %} {% block nested_form_widget -%} {% include 'BazookasAdminBundle:Form/Partials:_nested_form.html.twig' %} {%- endblock %} {# entity pickers #} {% block entity_picker_widget %} {% set button_class = '' %} {# FIXME this is pretty dirty look for a better way to access the original entity in the view #} {# NOTE I think no new query is executed because the entity is already in doctrine cache #} {% set transformer = transformer.setClass(form.vars.class) %} {% set entity = value is not empty ? transformer.reverseTransform(value) : null %} {% set display_value = entity is not empty ? attribute(entity, display_field) : '' %} {% if display_type == 'image' or display_type == 'asset' %} {% if display_value is not empty and not(display_value starts with 'http') and not(display_value starts with '/') %} {% set display_value = '/' ~ display_value %} {% endif %} {% set imageUrl = display_value %} {% if display_value is not empty and display_type == 'asset' %} {% set imageUrl = asset(display_value) | imagine_filter("thumbnail") %} {% endif %} {% set button_class = ' btn-block' %} {% else %}
{% endif %} {% if not disabled %} {% endif %} {% if display_type != 'image' %}
{% endif %} {% endblock %} {% block datetime_widget -%} {% if datetimepicker is defined and datetimepicker == true %} {{- form_widget(form.time, {'attr': attr}) -}} {{- form_widget(form.date, {'attr': attr}) -}} {% else %} {% if widget == 'single_text' %} {{- block('form_widget_simple') -}} {% else -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%}
{{- form_errors(form.time) -}} {{- form_errors(form.date) -}} {{- form_widget(form.time, { datetime: true, attr: attr} ) -}} {{- form_widget(form.date, { datetime: true, attr: attr} ) -}}
{%- endif %} {%- endif %} {%- endblock datetime_widget %} {% block choice_widget_collapsed -%} {% set attr = attr|merge({class: (attr.class|default('select2'))|trim}) %} {{- parent() -}} {%- endblock %} {% block choice_widget_expanded -%} {% if (form.children|length == 0) %} {{ attr.notFound|trans({}, translation_domain) }} {% endif %} {% if '-inline' in label_attr.class|default('') -%} {%- for child in form %} {{- form_widget(child, { parent_label_class: label_attr.class|default(''), translation_domain: choice_translation_domain, }) -}} {% endfor -%} {%- else -%}
{# this expansion allows for 'opt-groups' to be rendered when choosing to render a choicewidget form item as checkboxes #} {%- for key,child in choices %} {% if child.choices is defined %}
{{key|trans({}, translation_domain)}}
{% for choiceChild in child.choices %} {% for formChild in form %} {% if formChild.vars.value == choiceChild.value %} {{- form_widget(formChild, { parent_label_class: label_attr.class|default(''), translation_domain: choice_translation_domain, }) -}} {% endif %} {% endfor %} {% endfor %} {% else %} {% for formChild in form %} {% if formChild.vars.value == child.value %} {{- form_widget(formChild, { parent_label_class: label_attr.class|default(''), translation_domain: choice_translation_domain, }) -}} {% endif %} {% endfor %} {% endif %} {% endfor -%}
{%- endif %} {%- endblock choice_widget_expanded %} {% block image_preview_widget -%}
{%- endblock %} {% block youtube_upload_label %}{% endblock %} {% block youtube_upload_widget -%} {% trans_default_domain translation_domain %} {% include 'BazookasAdminBundle:Form/Partials:_youtube_upload_modal.html.twig' %} {%- endblock %} {% block media_folder_widget %} {% if expanded %} {{ block('choice_widget_expanded') }} {% else %} {{ block('media_folder_select_widget') }} {% endif %} {% endblock %} {% block media_folder_select_widget %} {% spaceless %} {% set attr = attr|merge({class: (attr.class|default('') ~ ' select2 form-control')|trim}) %} {% endspaceless %} {% endblock %} {% block media_folder_select_options %} {% spaceless %} {% for group_label, choice in options %} {% endfor %} {% endspaceless %} {% endblock %} {% block form_label -%} {% if tooltip_title is defined and tooltip_title is not same as(false) %} {%- set label_attr = label_attr|merge({ class: (label_attr.class|default('') ~ ' control-label add-' ~ tooltip_type)|trim, "data-toggle": tooltip_type, "data-placement": tooltip_placement, "data-original-title": tooltip_title|trans({}, translation_domain), "data-content": tooltip_content|trans({}, translation_domain), "data-trigger": tooltip_trigger }) -%} {% else %} {%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' control-label')|trim}) -%} {% endif %} {% if label is not same as(false) -%} {% if not compound -%} {% set label_attr = label_attr|merge({'for': id}) %} {%- endif -%} {% if required -%} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} {%- endif -%} {% if label is empty -%} {%- if label_format is not empty -%} {% set label = label_format|replace({ '%name%': name, '%id%': id, }) %} {%- else -%} {% set label = name|humanize %} {%- endif -%} {%- endif -%} {{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }} {% if tooltip_title is defined and tooltip_title != false %} {% endif %} {%- endif -%} {%- endblock form_label %} {% block text_widget -%} {# TODO: js is bundle specific because the fonts are often bundle specific can we solve this somehow? #} {% if renderAsIcon is defined and renderAsIcon %} {% spaceless %}
{% endspaceless %} {% else %} {{ block('form_widget') }} {% endif %} {%- endblock %} {% block date_widget -%} {% if widget == 'single_text' %}

{{- form_errors(form) -}}

{{- block('form_widget_simple') -}}
{% else -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} {% if datetime is not defined or not datetime -%}
{%- endif %} {{- date_pattern|replace({ '{{ year }}': form_widget(form.year), '{{ month }}': form_widget(form.month), '{{ day }}': form_widget(form.day), })|raw -}} {% if datetime is not defined or not datetime -%}
{%- endif -%} {% endif %} {%- endblock %} {% block time_widget -%} {% if widget == 'single_text' %}

{{- form_errors(form) -}}

{{- block('form_widget_simple') -}}
{% else -%} {% set attr = attr|merge({class: (attr.class|default('') ~ ' form-inline')|trim}) -%} {% if datetime is not defined or false == datetime -%}
{%- endif -%} {{- form_widget(form.hour) }}{% if with_minutes %}:{{ form_widget(form.minute) }}{% endif %}{% if with_seconds %}:{{ form_widget(form.second) }}{% endif %} {% if datetime is not defined or false == datetime -%}
{%- endif -%} {% endif %} {%- endblock %}