Skip to content

Commit

Permalink
Bootstrap 3 compatibility (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophie-mulard authored Apr 3, 2020
1 parent 1afb2b9 commit 4a5f7c3
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/Resources/views/bootstrap_3_layout.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{% block a2lix_translations_widget %}
{{ form_errors(form) }}

<div class="a2lix_translations">
<ul class="a2lix_translationsLocales nav nav-tabs" role="tablist">
{% for translationsFields in form %}
{% set locale = translationsFields.vars.name %}

<li{% if app.request.locale == locale %} class="active"{% endif %}>
<a href="#{{ translationsFields.vars.id }}_a2lix_translations-fields" data-toggle="tab" role="tab">
{{ translationsFields.vars.label|default(locale|humanize)|trans }}
{% if form.vars.default_locale == locale %}{{ '[Default]'|trans }}{% endif %}
{% if translationsFields.vars.required %}*{% endif %}
</a>
</li>
{% endfor %}
</ul>

<div class="a2lix_translationsFields tab-content">
{% for translationsFields in form %}
{% set locale = translationsFields.vars.name %}

<div id="{{ translationsFields.vars.id }}_a2lix_translations-fields" class="tab-pane {% if app.request.locale == locale %}active{% endif %} {% if not form.vars.valid %}sonata-ba-field-error{% endif %}" role="tabpanel">
{{ form_errors(translationsFields) }}
{{ form_widget(translationsFields) }}
</div>
{% endfor %}
</div>
</div>
{% endblock %}

{% block a2lix_translationsForms_widget %}
{{ block('a2lix_translations_widget') }}
{% endblock %}
38 changes: 38 additions & 0 deletions src/Resources/views/macros_bootstrap_3.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{#
Example:
{% import "@A2lixTranslationForm/macros_bootstrap_3.html.twig" as a2lixTranslations %}
{{ a2lixTranslations.partialTranslations(editForm.translations, ['title','description']) }}
{{ a2lixTranslations.partialTranslations(editForm.translations, ['url']) }}
#}

{% macro partialTranslations(form, fieldsNames) %}
{{ form_errors(form) }}

<div class="a2lix_translations">
<ul class="a2lix_translationsLocales nav nav-tabs" role="tablist">
{% for translationsFields in form %}
{% set locale = translationsFields.vars.name %}

<li{% if app.request.locale == locale %} class="active"{% endif %}>
<a href="#{{ translationsFields.vars.id }}_a2lix_translations-fields" data-toggle="tab" role="tab">
{{ translationsFields.vars.label|default(locale|humanize)|trans }}
{% if form.vars.default_locale == locale %}{{ '[Default]'|trans }}{% endif %}
{% if translationsFields.vars.required %}*{% endif %}
</a>
</li>
{% endfor %}
</ul>

<div class="a2lix_translationsFields tab-content">
{% for translationsFields in form %}
{% set locale = translationsFields.vars.name %}

<div id="{{ translationsFields.vars.id }}_a2lix_translations-fields" class="tab-pane {% if app.request.locale == locale %}active{% endif %} {% if not form.vars.valid %}sonata-ba-field-error{% endif %}" role="tabpanel">
{% for translationsField in translationsFields|filter(translationsField => translationsField.vars.name in fieldsNames) %}
{{ form_row(translationsField) }}
{% endfor %}
</div>
{% endfor %}
</div>
</div>
{% endmacro %}

0 comments on commit 4a5f7c3

Please sign in to comment.