[Form] Improved labels generated by default from form names
This commit is contained in:
parent
6e0b03a6e2
commit
658472193d
@ -200,6 +200,6 @@ class FieldType extends AbstractType
|
||||
|
||||
private function humanize($text)
|
||||
{
|
||||
return ucfirst(strtolower(str_replace('_', ' ', $text)));
|
||||
return ucfirst(trim(strtolower(preg_replace('/[_\s]+/', ' ', $text))));
|
||||
}
|
||||
}
|
||||
|
@ -188,6 +188,22 @@ class FieldTypeTest extends TypeTestCase
|
||||
$this->assertSame('test', $view->get('translation_domain'));
|
||||
}
|
||||
|
||||
public function testPassDefaultLabelToView()
|
||||
{
|
||||
$form = $this->factory->createNamed('field', '__test___field');
|
||||
$view = $form->createView();
|
||||
|
||||
$this->assertSame('Test field', $view->get('label'));
|
||||
}
|
||||
|
||||
public function testPassLabelToView()
|
||||
{
|
||||
$form = $this->factory->createNamed('field', '__test___field', null, array('label' => 'My label'));
|
||||
$view = $form->createView();
|
||||
|
||||
$this->assertSame('My label', $view->get('label'));
|
||||
}
|
||||
|
||||
public function testDefaultTranslationDomain()
|
||||
{
|
||||
$form = $this->factory->create('field');
|
||||
|
Reference in New Issue
Block a user