8000 [Bridge\Twig] fix bootstrap checkbox_row to render properly & remove spaceless by arkste · Pull Request #24728 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Bridge\Twig] fix bootstrap checkbox_row to render properly & remove spaceless #24728

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

Closed
wants to merge 11 commits into from
Closed
Prev Previous commit
Next Next commit
[TwigBridge] add whitespace control
  • Loading branch information
arkste committed Oct 30, 2017
commit 0e7e4b6d05c9829f19a0e202022b0b189f989738
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ col-sm-10
<div class="form-group">{#--#}
<div class="{{ block('form_label_class') }}"></div>{#--#}
<div class="{{ block('form_group_class') }}">
{{ form_widget(form) }}
{{- form_widget(form) -}}
</div>{#--#}
</div>
{% endblock submit_row %}
{%- endblock submit_row %}

{% block reset_row -%}
<div class="form-group">{#--#}
<div class="{{ block('form_label_class') }}"></div>{#--#}
<div class="{{ block('form_group_class') }}">
{{ form_widget(form) }}
{{- form_widget(form) -}}
</div>{#--#}
</div>
{% endblock reset_row %}
{%- endblock reset_row %}

{% block checkbox_row -%}
<div class="form-group{% if not valid %} has-error{% endif %}">{#--#}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@
{%- endblock form_widget_simple %}

{% block button_widget -%}
{% set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) %}
{%- set attr = attr|merge({class: (attr.class|default('btn-default') ~ ' btn')|trim}) -%}
{{- parent() -}}
{%- endblock button_widget %}

{% block checkbox_widget -%}
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
{% if 'checkbox-inline' in parent_label_class %}
{%- if 'checkbox-inline' in parent_label_class -%}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure those added - are needed? Does they make a difference as there are already - signs at the end of the line before and at the beginning of the next line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually they're not needed, but i tried to keep it similar to the bs4 layout, will remove them in both templates.

{{- form_label(form, null, { widget: parent() }) -}}
{% else -%}
{%- else -%}
<div class="checkbox">
{{- form_label(form, null, { widget: parent() }) -}}
</div>
{%- endif %}
{%- endif -%}
{%- endblock checkbox_widget %}

{% block radio_widget -%}
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
{% if 'radio-inline' in parent_label_class %}
{%- if 'radio-inline' in parent_label_class -%}
{{- form_label(form, null, { widget: parent() }) -}}
{% else -%}
{%- else -%}
<div class="radio">
{{- form_label(form, null, { widget: parent() }) -}}
</div>
{%- endif %}
{%- endif -%}
{%- endblock radio_widget %}

{# Labels #}
Expand Down Expand Up @@ -61,30 +61,30 @@
{{- block('checkbox_radio_label') -}}
{%- endblock radio_label %}

{% block checkbox_radio_label %}
{% block checkbox_radio_label -%}
{# Do not display the label if widget is not defined in order to prevent double label rendering #}
{% if widget is defined %}
{% if required %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) %}
{% endif %}
{% if parent_label_class is defined %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) %}
{% endif %}
{% if label is not same as(false) and label is empty %}
{%- if widget is defined -%}
{%- if required -%}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' required')|trim}) -%}
{%- endif -%}
{%- if parent_label_class is defined -%}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ parent_label_class)|trim}) -%}
{%- endif -%}
{%- if label is not same as(false) and label is empty -%}
{%- if label_format is not empty -%}
{% set label = label_format|replace({
{%- set label = label_format|replace({
'%name%': name,
'%id%': id,
}) %}
}) -%}
{%- else -%}
{% set label = name|humanize %}
{%- endif -%}
{% endif %}
{%- endif -%}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
</label>
{% endif %}
{% endblock checkbox_radio_label %}
{%- endif -%}
{%- endblock checkbox_radio_label %}

{# Rows #}

Expand Down
0