From aa6f345d1d3f7887c359ff836aaadd5ec14942f6 Mon Sep 17 00:00:00 2001 From: Howard Grigg Date: Wed, 26 Sep 2012 00:12:53 +1000 Subject: [PATCH] API FormField::name_to_label() for unlabelled fields Will convert camel case to spaces, e.g. "TotalAmount" to "Total Amount". --- forms/FormField.php | 2 +- tests/forms/FormTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forms/FormField.php b/forms/FormField.php index c1438e9f1..80cfc99d9 100644 --- a/forms/FormField.php +++ b/forms/FormField.php @@ -125,7 +125,7 @@ class FormField extends RequestHandler { */ 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); diff --git a/tests/forms/FormTest.php b/tests/forms/FormTest.php index d97257a1f..fbbcea1d7 100644 --- a/tests/forms/FormTest.php +++ b/tests/forms/FormTest.php @@ -211,7 +211,7 @@ class FormTest extends FunctionalTest { $this->assertPartialMatchBySelector( '#SomeRequiredField span.required', array( - '"SomeRequiredField" is required' + '"Some Required Field" is required' ), 'Required fields show a notification on field when left blank' );