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.
This commit is contained in:
commit
37d049122c
@ -52,7 +52,7 @@ class FieldType extends AbstractType
|
|||||||
->setAttribute('error_mapping', $options['error_mapping'])
|
->setAttribute('error_mapping', $options['error_mapping'])
|
||||||
->setAttribute('max_length', $options['max_length'])
|
->setAttribute('max_length', $options['max_length'])
|
||||||
->setAttribute('pattern', $options['pattern'])
|
->setAttribute('pattern', $options['pattern'])
|
||||||
->setAttribute('label', $options['label'] ?: $this->humanize($builder->getName()))
|
->setAttribute('label', strlen($options['label']) > 0 ? $options['label'] : $this->humanize($builder->getName()))
|
||||||
->setAttribute('attr', $options['attr'] ?: array())
|
->setAttribute('attr', $options['attr'] ?: array())
|
||||||
->setAttribute('invalid_message', $options['invalid_message'])
|
->setAttribute('invalid_message', $options['invalid_message'])
|
||||||
->setAttribute('invalid_message_parameters', $options['invalid_message_parameters'])
|
->setAttribute('invalid_message_parameters', $options['invalid_message_parameters'])
|
||||||
|
@ -238,4 +238,12 @@ class FieldTypeTest extends TypeTestCase
|
|||||||
$form = $this->factory->create('field', null, array('attr' => ''));
|
$form = $this->factory->create('field', null, array('attr' => ''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/symfony/symfony/issues/6862
|
||||||
|
public function testPassZeroLabelToView()
|
||||||
|
{
|
||||||
|
$view = $this->factory->create('field', null, array('label' => 0))->createView();
|
||||||
|
|
||||||
|
$this->assertEquals('0', $view->get('label'));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user