Skip to content

Commit

Permalink
BUGFIX Ensure that CheckboxField setValue() always sets it's value as…
Browse files Browse the repository at this point in the history
… either 1 or 0, even though the request data can come through as "on"

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@75045 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
Sean Harvey authored and Sam Minnee committed Feb 2, 2011
1 parent 756735b commit 578a53a
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions forms/CheckboxField.php
Expand Up @@ -5,13 +5,16 @@
* @subpackage fields-basic
*/
class CheckboxField extends FormField {
/**
* Returns a single checkbox field - used by templates.
*
* Shouldn't this have a value?
*/

protected $disabled;

function setValue($value) {
$this->value = ($value) ? 1 : 0;
}

function dataValue() {
return ($this->value) ? 1 : 0;
}

function Field() {
$attributes = array(
Expand All @@ -27,12 +30,7 @@ function Field() {

return $this->createTag('input', $attributes);
}


function dataValue() {
return $this->value ? 1 : 0;
}


/**
* Checkboxes use the RightLabelledFieldHolder template, to put the field on the left
* and the label on the right. See {@link FormField::FieldHolder} for more information about
Expand Down

0 comments on commit 578a53a

Please sign in to comment.