From 9587c6ccf9a4d90f670c2972614149a97323df6f Mon Sep 17 00:00:00 2001 From: Wesley Hollevoet Date: Sat, 20 Apr 2013 12:20:47 +0200 Subject: [PATCH 1/4] Set default value for label if no value is supplied. --- FormBuilder.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/FormBuilder.php b/FormBuilder.php index c6fb6c3..3dfa472 100644 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -176,12 +176,16 @@ class FormBuilder { * @param array $options * @return string */ - public function label($name, $value, $options = array()) + public function label($name, $value='', $options = array()) { $this->labels[] = $name; $options = $this->html->attributes($options); + if (!$value) { + $value = ucfirst(str_replace('_', ' ', $name)) . ': '; + } + return ''; } From b26a9e1072c17d0ba24860890eb857e92072aff7 Mon Sep 17 00:00:00 2001 From: wesleyh Date: Sat, 20 Apr 2013 23:30:04 +0300 Subject: [PATCH 2/4] Coding Standards Changed to using null instead of '' and remove the ': ' at the end of the label value. (Though I myself quite like this..) --- FormBuilder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/FormBuilder.php b/FormBuilder.php index 3dfa472..59221fe 100644 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -176,14 +176,15 @@ class FormBuilder { * @param array $options * @return string */ - public function label($name, $value='', $options = array()) + public function label($name, $value=null, $options = array()) { $this->labels[] = $name; $options = $this->html->attributes($options); - if (!$value) { - $value = ucfirst(str_replace('_', ' ', $name)) . ': '; + if (is_null($value)) + { + $value = ucfirst(str_replace('_', ' ', $name)); } return ''; From 0f63e047d9c5677ebfdec0e25cf0dbe37fa9430d Mon Sep 17 00:00:00 2001 From: wesleyh Date: Sun, 21 Apr 2013 10:23:35 +0300 Subject: [PATCH 3/4] Spaces around equals sign. --- FormBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FormBuilder.php b/FormBuilder.php index 59221fe..fe7fef9 100644 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -176,7 +176,7 @@ class FormBuilder { * @param array $options * @return string */ - public function label($name, $value=null, $options = array()) + public function label($name, $value = null, $options = array()) { $this->labels[] = $name; From dea61f2e448ae47312d079cc0650322a697feaf9 Mon Sep 17 00:00:00 2001 From: wesleyh Date: Mon, 22 Apr 2013 11:16:47 +0300 Subject: [PATCH 4/4] Updated to use ucwords instead of ucfirst This ensures each word is capitalized instead of just the first. --- FormBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FormBuilder.php b/FormBuilder.php index fe7fef9..d0cf552 100644 --- a/FormBuilder.php +++ b/FormBuilder.php @@ -184,7 +184,7 @@ class FormBuilder { if (is_null($value)) { - $value = ucfirst(str_replace('_', ' ', $name)); + $value = ucwords(str_replace('_', ' ', $name)); } return '';