Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
arkste wants to merge11 commits intosymfony:3.4fromarkste:spaceless-bootstrap-fix
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
11 commits
Select commitHold shift + click to select a range
60105bc
[TwigBridge] fix bootstrap 3 & 4 checkbow row rendering
arksteOct 30, 2017
1fd87b0
[TwigBridge] Add Bootstrap 3 & 4 checkbow row tests
arksteOct 30, 2017
b5cdb92
[TwigBridge] fix bootstrap 4 tests for #24703
arksteOct 30, 2017
b370fe9
[TwigBridge] add whitespace control to form_label
arksteOct 30, 2017
0e7e4b6
[TwigBridge] add whitespace control
arksteOct 30, 2017
6dbdce0
[TwigBridge] bump dep on symfony/form
arksteOct 30, 2017
9a0e8cb
[TwigBridge] revert form_label_class & form_group_class change
arksteOct 30, 2017
fe4eda6
[TwigBridge] revert form_label_class & form_group_class change
arksteOct 30, 2017
f0e97ba
[TwigBridge] remove unnecessary whitespace control
arksteOct 30, 2017
6f07a0f
[TwigBridge] remove unnecessary whitespace control
arksteOct 30, 2017
cbecd02
[TwigBridge] EOL added
arksteOct 30, 2017
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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,12 @@
{# Labels #}

{% block form_label -%}
{% spaceless %}
{% if label is same as(false) %}
{%- if label is same as(false) -%}
<div class="{{ block('form_label_class') }}"></div>
{% else %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) %}
{%- else-%}
{%- set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim})-%}
{{- parent() -}}
{% endif %}
{% endspaceless %}
{%- endif -%}
{%- endblock form_label %}

{% block form_label_class -%}
Expand All@@ -35,27 +33,33 @@ col-sm-2
{%- endblock form_row %}

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

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

{% block form_group_class -%}
col-sm-10
{%- endblock form_group_class %}

{% block checkbox_row -%}
<div class="form-group{% if not valid %} has-error{% endif %}">{#--#}
<div class="{{ block('form_label_class') }}"></div>{#--#}
<div class="{{ block('form_group_class') }}">
{{- form_widget(form) -}}
{{- form_errors(form) -}}
</div>{#--#}
</div>
{%- endblock checkbox_row %}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
{%- 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 %}

Expand All@@ -22,18 +22,18 @@
<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 DownExpand 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 DownExpand Up@@ -123,15 +123,10 @@
{%- endblock datetime_row %}

{% block checkbox_row -%}
{% spaceless %}
<div class="form-group{% if not valid %} has-error{% endif %}">
<div class="{{ block('form_label_class') }}"></div>
<div class="{{ block('form_group_class') }}">
{{- form_widget(form) -}}
{{- form_errors(form) -}}
</div>
{{- form_widget(form) -}}
{{- form_errors(form) -}}
</div>
{% endspaceless %}
{%- endblock checkbox_row %}

{% block radio_row -%}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,23 +47,33 @@ col-sm-2
{%- endblock fieldset_form_row %}

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

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

{% block form_group_class -%}
col-sm-10
{%- endblock form_group_class %}

{% block checkbox_row -%}
<div class="form-group row">{#--#}
<div class="{{ block('form_label_class') }}"></div>{#--#}
<div class="{{ block('form_group_class') }}">
{{- form_widget(form) -}}
{{- form_errors(form) -}}
</div>{#--#}
</div>
{%- endblock checkbox_row %}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,9 +24,9 @@
{% block checkbox_widget -%}
{%- set parent_label_class = parent_label_class|default(label_attr.class|default('')) -%}
{%- set attr = attr|merge({class: attr.class|default('form-check-input')}) -%}
{%- if 'checkbox-inline' in parent_label_class-%}
{% if 'checkbox-inline' in parent_label_class %}
{{- form_label(form, null, { widget: parent() }) -}}
{%- else -%}
{% else -%}
<div class="form-check">
{{- form_label(form, null, { widget: parent() }) -}}
</div>
Expand Down
2 changes: 1 addition & 1 deletionsrc/Symfony/Bridge/Twig/composer.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,7 +24,7 @@
"symfony/asset": "~2.8|~3.0|~4.0",
"symfony/dependency-injection": "~2.8|~3.0|~4.0",
"symfony/finder": "~2.8|~3.0|~4.0",
"symfony/form": "~3.4|~4.0",
"symfony/form": "~3.4-beta2|~4.0",
"symfony/http-foundation": "^3.3.11|~4.0",
"symfony/http-kernel": "~3.2|~4.0",
"symfony/polyfill-intl-icu": "~1.0",
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -154,4 +154,13 @@ public function testStartTagWithExtraAttributes()

$this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="foobar form-horizontal">', $html);
}

public function testCheckboxRow()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType');
$view = $form->createView();
$html = $this->renderRow($view, array('label' => 'foo'));

$this->assertMatchesXpath($html, '/div[@class="form-group"]/div[@class="col-sm-2" or @class="col-sm-10"]', 2);
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,8 +26,8 @@ public function testLabelOnForm()
$html = $this->renderLabel($view);

$this->assertMatchesXpath($html,
'/label
[@class="col-form-label col-sm-2 form-control-label required"]
'/legend
[@class="col-form-label col-sm-2col-form-legend required"]
[.="[trans]Name[/trans]"]
'
);
Expand DownExpand Up@@ -118,7 +118,7 @@ public function testLegendOnExpandedType()

$this->assertMatchesXpath($html,
'/legend
[@class="col-sm-2 col-form-legendform-control-labelrequired"]
[@class="col-sm-2 col-form-legend required"]
[.="[trans]Custom label[/trans]"]
'
);
Expand DownExpand Up@@ -178,4 +178,13 @@ public function testStartTagWithExtraAttributes()

$this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="foobar">', $html);
}

public function testCheckboxRow()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType');
$view = $form->createView();
$html = $this->renderRow($view, array('label' => 'foo'));

$this->assertMatchesXpath($html, '/div[@class="form-group row"]/div[@class="col-sm-2" or @class="col-sm-10"]', 2);
}
}
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,8 +28,8 @@ public function testLabelOnForm()
$html = $this->renderLabel($view);

$this->assertMatchesXpath($html,
'/label
[@class="form-control-label required"]
'/legend
[@class="col-form-legend required"]
[.="[trans]Name[/trans]"]
'
);
Expand DownExpand Up@@ -120,7 +120,7 @@ public function testLegendOnExpandedType()

$this->assertMatchesXpath($html,
'/legend
[@class="col-form-legendform-control-labelrequired"]
[@class="col-form-legend required"]
[.="[trans]Custom label[/trans]"]
'
);
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp