Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-3242: Added twig macros for rendering form fields in edit base view #492

Merged
merged 2 commits into from
Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 30 additions & 32 deletions src/bundle/Resources/views/themes/admin/content/edit_base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@
{% include '@ibexadesign/ui/anchor_navigation_menu.html.twig' with anchor_params %}
{% endblock %}

{% macro renderFormField(formField) -%}
{% if not formField.rendered %}
{% if formField.value is defined %}
{{- form_widget(formField) -}}
{% else %}
<div class="ibexa-field-edit ibexa-field-edit--eznoneditable">
{{- form_label(formField) -}}
<p class="non-editable">
{{ 'content.field.non_editable'|trans|desc('This Field Type is not editable') }}
</p>
{% do formField.setRendered() %}
</div>
{% endif %}
{% endif %}
{%- endmacro -%}

{% macro renderFieldGroup(group, form) -%}
{% for field in group %}
{% set formField = form.fieldsData[field] %}

{{ _self.renderFormField(formField) }}
{% endfor %}
{%- endmacro -%}

{% block content %}
<div class="ibexa-edit-content__container">
{% block form_before %}{% endblock %}
Expand All @@ -34,47 +58,21 @@
<div class="ibexa-anchor-navigation-sections">
{% for key, group in grouped_fields %}
{% embed '@ibexadesign/ui/anchor_navigation_section.html.twig' with {
anchor_section_key: key
anchor_section_key: key,
parent_self: _self,
} %}
{% trans_default_domain 'content_edit' %}
{% import parent_self as parent_self %}

{% block anchor_section_body %}
{% for field in group %}
{% set formField = form.fieldsData[field] %}

{% if not formField.rendered %}
{% if formField.value is defined %}
{{- form_widget(formField) -}}
{% else %}
<div class="ibexa-field-edit ibexa-field-edit--eznoneditable">
{{- form_label(formField) -}}
<p class="non-editable">
{{ "content.field.non_editable"|trans|desc('This Field Type is not editable') }}
</p>
{% do formField.setRendered() %}
</div>
{% endif %}
{% endif %}
{% endfor %}
{{ parent_self.renderFieldGroup(group, form) }}
{% endblock %}
{% endembed %}
{% endfor %}
</div>
{% else %}
{% for field in form.fieldsData %}
{% if not field.rendered %}
{% if field.value is defined %}
{{- form_widget(field) -}}
{% else %}
<div class="ibexa-field-edit ibexa-field-edit--eznoneditable">
{{- form_label(field) -}}
<p class="non-editable">
{{ "content.field.non_editable"|trans|desc('This Field Type is not editable') }}
</p>
{% do field.setRendered() %}
</div>
{% endif %}
{% endif %}
{% for formField in form.fieldsData %}
{{ _self.renderFormField(formField) }}
{%- endfor %}
{% endif %}
{% endblock %}
Expand Down