8000 merged branch bschussek/issue6862 (PR #7150) · weaverryan/symfony@37d0491 · GitHub
[go: up one dir, main page]

Skip to content

Commit 37d0491

Browse files
committed
merged branch bschussek/issue6862 (PR symfony#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 | symfony#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

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

Lines 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

Lines changed: 8 additions & 0 deletions
< 8241 /div>
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