From 8605743ea68d9e9841546da0e8e1b3801dfddaff Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Thu, 23 Apr 2009 12:12:51 +0000 Subject: [PATCH] BUGFIX Make sure that CheckboxField sets it's value as either 1 or 0, so that saveInto() saves the proper boolean value MINOR Added tests for observing the dataValue() and Value() return values based on setting different values to the field git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@75046 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/CheckboxField.php | 4 ++++ forms/FormField.php | 4 ++-- tests/forms/CheckboxSetFieldTest.php | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/forms/CheckboxField.php b/forms/CheckboxField.php index 8e697c957..5ed1d7371 100755 --- a/forms/CheckboxField.php +++ b/forms/CheckboxField.php @@ -16,6 +16,10 @@ class CheckboxField extends FormField { return ($this->value) ? 1 : 0; } + function Value() { + return ($this->value) ? 1 : 0; + } + function Field() { $attributes = array( 'type' => 'checkbox', diff --git a/forms/FormField.php b/forms/FormField.php index 9cbc74ec2..23cf1ab62 100644 --- a/forms/FormField.php +++ b/forms/FormField.php @@ -113,14 +113,14 @@ class FormField extends RequestHandler { /** * Returns the field message, used by form validation */ - function Message(){ + function Message() { return $this->message; } /** * Returns the field message type, used by form validation */ - function MessageType(){ + function MessageType() { return $this->messageType; } diff --git a/tests/forms/CheckboxSetFieldTest.php b/tests/forms/CheckboxSetFieldTest.php index 7370c643d..db378e559 100644 --- a/tests/forms/CheckboxSetFieldTest.php +++ b/tests/forms/CheckboxSetFieldTest.php @@ -1,5 +1,8 @@