From 7e002c23edc5fb5db70935591aa6adeda25fc7fb Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 2 Jul 2006 18:05:42 +0000 Subject: Merge from 3.0 branch till 1224. --- framework/Web/UI/WebControls/TCheckBox.php | 46 +++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'framework/Web/UI/WebControls/TCheckBox.php') diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index 6fe562c9..04733f95 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -60,13 +60,10 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl public function loadPostData($key,$values) { $checked=$this->getChecked(); - if(isset($values[$key])!=$checked) - { - $this->setChecked(!$checked); - return true; - } - else - return false; + if($newChecked=isset($values[$key])) + $this->setValue($values[$key]); + $this->setChecked($newChecked); + return $newChecked!==$checked; } /** @@ -133,6 +130,22 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $this->setViewState('Text',$value,''); } + /** + * @return string the value of the checkbox. Defaults to empty. + */ + public function getValue() + { + return $this->getViewState('Value',''); + } + + /** + * @param string the value of the checkbox + */ + public function setValue($value) + { + $this->setViewState('Value',$value,''); + } + /** * @return string the alignment (Left or Right) of the text caption, defaults to Right. */ @@ -309,13 +322,18 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl */ protected function getValueAttribute() { - $attributes=$this->getViewState('InputAttributes',null); - if($attributes && $attributes->contains('value')) - return $attributes->itemAt('value'); - else if($this->hasAttribute('value')) - return $this->getAttribute('value'); + if(($value=$this->getValue())!=='') + return $value; else - return ''; + { + $attributes=$this->getViewState('InputAttributes',null); + if($attributes && $attributes->contains('value')) + return $attributes->itemAt('value'); + else if($this->hasAttribute('value')) + return $this->getAttribute('value'); + else + return ''; + } } /** @@ -345,7 +363,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl if($clientID!=='') $writer->addAttribute('id',$clientID); $writer->addAttribute('type','checkbox'); - if(($value = $this->getValueAttribute()) !== '') + if(($value=$this->getValueAttribute())!=='') $writer->addAttribute('value',$value); if(!empty($onclick)) $writer->addAttribute('onclick',$onclick); -- cgit v1.2.3