diff --git a/Phorm/Field/Checkbox.class.php b/Phorm/Field/Checkbox.class.php old mode 100644 new mode 100755 index 03acf4f..37e08c3 --- a/Phorm/Field/Checkbox.class.php +++ b/Phorm/Field/Checkbox.class.php @@ -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 @@ -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; } /** @@ -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'); } /** @@ -97,6 +105,7 @@ public function validate_required_field($value) */ public function import_value($value) { + $this->checked = $this->user_checked; return $this->checked; }