Permalink
Browse files

API FormField::name_to_label() for unlabelled fields

Will convert camel case to spaces, e.g. "TotalAmount"
to "Total Amount".
  • Loading branch information...
1 parent 92e62eb commit aa6f345d1d3f7887c359ff836aaadd5ec14942f6 @howardgrigg howardgrigg committed with chillu Sep 25, 2012
Showing with 2 additions and 2 deletions.
  1. +1 −1 forms/FormField.php
  2. +1 −1 tests/forms/FormTest.php
View
@@ -125,7 +125,7 @@ public static function name_to_label($fieldName) {
*/
public function __construct($name, $title = null, $value = null) {
$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);
@@ -211,7 +211,7 @@ public function testSessionValidationMessage() {
$this->assertPartialMatchBySelector(
'#SomeRequiredField span.required',
array(
- '"SomeRequiredField" is required'
+ '"Some Required Field" is required'
),
'Required fields show a notification on field when left blank'
);

0 comments on commit aa6f345

Please sign in to comment.