Skip to content

Commit

Permalink
[Form] Fixed "label" option to accept the value "0"
Browse files Browse the repository at this point in the history
  • Loading branch information
webmozart committed Feb 21, 2013
1 parent cf15198 commit f8812b2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -52,7 +52,7 @@ public function buildForm(FormBuilder $builder, array $options)
->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'])
Expand Down
Expand Up @@ -238,4 +238,12 @@ public function testAttributesException()
$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'));
}

}

0 comments on commit f8812b2

Please sign in to comment.