Skip to content

Commit

Permalink
Merge pull request jordanlev#5 from tf198/master
Browse files Browse the repository at this point in the history
Checkbox Bug
  • Loading branch information
jordanlev committed Mar 3, 2012
2 parents e981dc3 + 3a8a35b commit 0ca044c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Phorm/Field/Checkbox.class.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class Phorm_Field_Checkbox extends Phorm_Field
* @var boolean
*/
private $checked;

/**
* True when the user data field is checked.
* @var boolean
*/
private $user_checked;

/**
* @param string $label the field's text label
Expand All @@ -31,6 +37,7 @@ public function __construct($label, array $validators=array(), array $attributes
parent::__construct($label, $validators, $attributes);
parent::set_value('on');
$this->checked = false;
$this->user_checked = false;
}

/**
Expand All @@ -42,6 +49,7 @@ public function __construct($label, array $validators=array(), array $attributes
public function set_value($value)
{
$this->checked = (boolean) $value;
$this->user_checked = ($value === 'on');
}

/**
Expand Down Expand Up @@ -97,6 +105,7 @@ public function validate_required_field($value)
*/
public function import_value($value)
{
$this->checked = $this->user_checked;
return $this->checked;
}

Expand Down

0 comments on commit 0ca044c

Please sign in to comment.