API FormField::name_to_label() for unlabelled fields

Will convert camel case to spaces, e.g. "TotalAmount"
to "Total Amount".
This commit is contained in:
Howard Grigg 2012-09-26 00:12:53 +10:00 committed by Ingo Schommer
parent 92e62ebb91
commit aa6f345d1d
2 changed files with 2 additions and 2 deletions

View File

@ -125,7 +125,7 @@ class FormField extends RequestHandler {
*/ */
public function __construct($name, $title = null, $value = null) { public function __construct($name, $title = null, $value = null) {
$this->name = $name; $this->name = $name;
$this->title = ($title === null) ? $name : $title; $this->title = ($title === null) ? self::name_to_label($name) : $title;
if($value !== NULL) $this->setValue($value); if($value !== NULL) $this->setValue($value);

View File

@ -211,7 +211,7 @@ class FormTest extends FunctionalTest {
$this->assertPartialMatchBySelector( $this->assertPartialMatchBySelector(
'#SomeRequiredField span.required', '#SomeRequiredField span.required',
array( array(
'"SomeRequiredField" is required' '"Some Required Field" is required'
), ),
'Required fields show a notification on field when left blank' 'Required fields show a notification on field when left blank'
); );