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

Appearance settings

Commit 37d0491

Browse filesBrowse files
committed
merged branch bschussek/issue6862 (PR #7150)
This PR was merged into the 2.0 branch. Commits ------- f8812b2 [Form] Fixed "label" option to accept the value "0" Discussion ---------- [Form] Fixed "label" option to accept the value "0" | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6862 | License | MIT | Doc PR | - @fabpot: This commit will cause troubles when merging 2.0 into 2.1 and up. Tell me if you need help upon conflict resolution.
2 parents cf15198 + f8812b2 commit 37d0491
Copy full SHA for 37d0491

File tree

2 files changed

+9
-1
lines changed
Filter options

2 files changed

+9
-1
lines changed

‎src/Symfony/Component/Form/Extension/Core/Type/FieldType.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/FieldType.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function buildForm(FormBuilder $builder, array $options)
5252
->setAttribute('error_mapping', $options['error_mapping'])
5353
->setAttribute('max_length', $options['max_length'])
5454
->setAttribute('pattern', $options['pattern'])
55-
->setAttribute('label', $options['label'] ?: $this->humanize($builder->getName()))
55+
->setAttribute('label', strlen($options['label']) > 0 ? $options['label'] : $this->humanize($builder->getName()))
5656
->setAttribute('attr', $options['attr'] ?: array())
5757
->setAttribute('invalid_message', $options['invalid_message'])
5858
->setAttribute('invalid_message_parameters', $options['invalid_message_parameters'])

‎tests/Symfony/Tests/Component/Form/Extension/Core/Type/FieldTypeTest.php

Copy file name to clipboardExpand all lines: tests/Symfony/Tests/Component/Form/Extension/Core/Type/FieldTypeTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,12 @@ public function testAttributesException()
238238
$form = $this->factory->create('field', null, array('attr' => ''));
239239
}
240240

241+
// https://github.com/symfony/symfony/issues/6862
242+
public function testPassZeroLabelToView()
243+
{
244+
$view = $this->factory->create('field', null, array('label' => 0))->createView();
245+
246+
$this->assertEquals('0', $view->get('label'));
247+
}
248+
241249
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.