[Form]fixed FormRenderer::humanize() to humanize camel cased label
This commit is contained in:
parent
eb2bcc5db9
commit
8adb0e3673
@ -1,6 +1,12 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
|
||||
2.3.0
|
||||
------
|
||||
|
||||
* changed FormRenderer::humanize() to humanize also camel cased field name
|
||||
|
||||
2.2.0
|
||||
-----
|
||||
|
||||
|
@ -280,6 +280,6 @@ class FormRenderer implements FormRendererInterface
|
||||
*/
|
||||
public function humanize($text)
|
||||
{
|
||||
return ucfirst(trim(strtolower(preg_replace('/[_\s]+/', ' ', $text))));
|
||||
return ucfirst(trim(strtolower(preg_replace(array('/([A-Z])/', '/[_\s]+/'), array('_$1', ' '), $text))));
|
||||
}
|
||||
}
|
||||
|
18
src/Symfony/Component/Form/Tests/FormRendererTest.php
Normal file
18
src/Symfony/Component/Form/Tests/FormRendererTest.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\Form\Test;
|
||||
|
||||
class FormRendererTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testHumanize()
|
||||
{
|
||||
$renderer = $this->getMockBuilder('Symfony\Component\Form\FormRenderer')
|
||||
->setMethods(null)
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
|
||||
$this->assertEquals('Is active', $renderer->humanize('is_active'));
|
||||
$this->assertEquals('Is active', $renderer->humanize('isActive'));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user