[Form] Fixed "label" option to accept the value "0"
This commit is contained in:
parent
cf15198faa
commit
f8812b28f3
@ -52,7 +52,7 @@ class FieldType extends AbstractType
|
||||
->setAttribute('error_mapping', $options['error_mapping'])
|
||||
->setAttribute('max_length', $options['max_length'])
|
||||
->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('invalid_message', $options['invalid_message'])
|
||||
->setAttribute('invalid_message_parameters', $options['invalid_message_parameters'])
|
||||
|
@ -238,4 +238,12 @@ class FieldTypeTest extends TypeTestCase
|
||||
$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