From 0c1b167cebac83e63c05ef780f012d7117ed8b81 Mon Sep 17 00:00:00 2001 From: xue <> Date: Sun, 22 Jan 2006 00:16:20 +0000 Subject: Fixed a few issues with TCheckBox, TLinkButton and TRadioButton. --- framework/Web/UI/WebControls/TCheckBox.php | 38 ++++++++++++++++++--------- framework/Web/UI/WebControls/TLinkButton.php | 2 +- framework/Web/UI/WebControls/TRadioButton.php | 14 ---------- 3 files changed, 26 insertions(+), 28 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index ae6dc8e4..47fabd20 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -168,7 +168,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl */ public function setChecked($value) { - $this->setViewState('Checked',$value,false); + $this->setViewState('Checked',TPropertyValue::ensureBoolean($value),false); } /** @@ -185,7 +185,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl */ public function setAutoPostBack($value) { - $this->setViewState('AutoPostBack',$value,false); + $this->setViewState('AutoPostBack',TPropertyValue::ensureBoolean($value),false); } /** @@ -247,12 +247,10 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $writer->addAttribute('title',$tooltip); $needSpan=true; } - $onclick=null; if($this->getHasAttributes()) { $attributes=$this->getAttributes(); $value=$attributes->remove('value'); - $onclick=$attributes->remove('onclick'); if($attributes->getCount()) { $writer->addAttributes($attributes); @@ -269,16 +267,16 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl if($this->getTextAlign()==='Left') { $this->renderLabel($writer,$clientID,$text); - $this->renderInputTag($writer,$clientID,$onclick); + $this->renderInputTag($writer,$clientID); } else { - $this->renderInputTag($writer,$clientID,$onclick); + $this->renderInputTag($writer,$clientID); $this->renderLabel($writer,$clientID,$text); } } else - $this->renderInputTag($writer,$clientID,$onclick); + $this->renderInputTag($writer,$clientID); if($needSpan) $writer->renderEndTag(); } @@ -292,7 +290,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl return $attributes; else { - $attributes=new TMap; + $attributes=new TAttributeCollection; $this->setViewState('LabelAttributes',$attributes,null); return $attributes; } @@ -307,12 +305,26 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl return $attributes; else { - $attributes=new TMap; + $attributes=new TAttributeCollection; $this->setViewState('InputAttributes',$attributes,null); return $attributes; } } + /** + * @return string the value attribute to be rendered + */ + protected function getValueAttribute() + { + if(($value=$this->getAttribute('value'))===null) + { + $value=$this->getID(); + return $value===''?$this->getUniqueID():$value; + } + else + return $value; + } + /** * Renders a label beside the checkbox. * @param THtmlWriter the writer for the rendering purpose @@ -333,13 +345,13 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl * Renders a checkbox input element. * @param THtmlWriter the writer for the rendering purpose * @param string checkbox id - * @param string onclick attribute value for the checkbox */ - protected function renderInputTag($writer,$clientID,$onclick) + protected function renderInputTag($writer,$clientID) { if($clientID!=='') $writer->addAttribute('id',$clientID); $writer->addAttribute('type','checkbox'); + $writer->addAttribute('value',$this->getValueAttribute()); if(($uniqueID=$this->getUniqueID())!=='') $writer->addAttribute('name',$uniqueID); if($this->getChecked()) @@ -362,8 +374,8 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl } /** - * Sets the post back options for this textbox. - * @return TPostBackOptions + * Sets the post back options for this checkbox. + * @return array */ public function getPostBackOptions() { diff --git a/framework/Web/UI/WebControls/TLinkButton.php b/framework/Web/UI/WebControls/TLinkButton.php index c24119e5..619f8e77 100644 --- a/framework/Web/UI/WebControls/TLinkButton.php +++ b/framework/Web/UI/WebControls/TLinkButton.php @@ -185,7 +185,7 @@ class TLinkButton extends TWebControl implements IPostBackEventHandler */ public function setCausesValidation($value) { - $this->setViewState('CausesValidation',$value,true); + $this->setViewState('CausesValidation',TPropertyValue::ensureBoolean($value),true); } /** diff --git a/framework/Web/UI/WebControls/TRadioButton.php b/framework/Web/UI/WebControls/TRadioButton.php index ee53107a..e756cba6 100644 --- a/framework/Web/UI/WebControls/TRadioButton.php +++ b/framework/Web/UI/WebControls/TRadioButton.php @@ -127,20 +127,6 @@ class TRadioButton extends TCheckBox return $this->_uniqueGroupName; } - /** - * @return string the value attribute to be rendered - */ - private function getValueAttribute() - { - if(($value=$this->getAttribute('value'))===null) - { - $value=$this->getID(); - return $value===''?$this->getUniqueID():$value; - } - else - return $value; - } - /** * Renders a radiobutton input element. * @param THtmlWriter the writer for the rendering purpose -- cgit v1.2.3