diff options
author | mikl <> | 2008-04-17 16:16:03 +0000 |
---|---|---|
committer | mikl <> | 2008-04-17 16:16:03 +0000 |
commit | 2ff1a4bcb650b0dce241c2d947fbf59759c2efff (patch) | |
tree | adc1c4fa758f67f5c404f7f1d320fd5dbf8296e9 /framework/Web/UI/WebControls/TCheckBox.php | |
parent | 5f6f3f560b826b6b4f9f98bb4e83724b28e454d6 (diff) |
Fixed #622
Diffstat (limited to 'framework/Web/UI/WebControls/TCheckBox.php')
-rw-r--r-- | framework/Web/UI/WebControls/TCheckBox.php | 39 |
1 files changed, 25 insertions, 14 deletions
diff --git a/framework/Web/UI/WebControls/TCheckBox.php b/framework/Web/UI/WebControls/TCheckBox.php index 7a0fc603..4061f217 100644 --- a/framework/Web/UI/WebControls/TCheckBox.php +++ b/framework/Web/UI/WebControls/TCheckBox.php @@ -40,7 +40,7 @@ * @package System.Web.UI.WebControls
* @since 3.0
*/
-class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatable, IDataRenderer
+class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatable, IDataRenderer, IControlContainer
{
private $_dataChanged=false;
@@ -268,6 +268,14 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl }
/**
+ * @return string the id of the surrounding tag or this clientID if no such tag present
+ */
+ public function getContainerClientID()
+ {
+ return $this->getSpanNeeded() ? $this->getClientID().'_parent' : $this->getClientID();
+ }
+
+ /**
* Renders the checkbox control.
* This method overrides the parent implementation by rendering a checkbox input element
* and a span element if needed.
@@ -276,17 +284,10 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl public function render($writer)
{
$this->getPage()->ensureRenderInForm($this);
- $needSpan=false;
if($this->getHasStyle())
- {
$this->getStyle()->addAttributesToRender($writer);
- $needSpan=true;
- }
if(($tooltip=$this->getToolTip())!=='')
- {
$writer->addAttribute('title',$tooltip);
- $needSpan=true;
- }
if($this->getHasAttributes())
{
$attributes=$this->getAttributes();
@@ -295,17 +296,17 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl if(($onclick=$attributes->remove('onclick'))===null)
$onclick='';
if($attributes->getCount())
- {
$writer->addAttributes($attributes);
- $needSpan=true;
- }
if($value!==null)
$attributes->add('value',$value);
}
else
$onclick='';
- if($needSpan)
+ if($needspan=$this->getSpanNeeded())
+ {
+ $writer->addAttribute('id',$this->getContainerClientID());
$writer->renderBeginTag('span');
+ }
$clientID=$this->getClientID();
if(($text=$this->getText())!=='')
{
@@ -322,7 +323,7 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl }
else
$this->renderInputTag($writer,$clientID,$onclick);
- if($needSpan)
+ if($needspan)
$writer->renderEndTag();
}
@@ -391,6 +392,16 @@ class TCheckBox extends TWebControl implements IPostBackDataHandler, IValidatabl $this->setViewState('EnableClientScript',TPropertyValue::ensureBoolean($value),true);
}
+ /**
+ * Check if we need a span tag to surround this control. The span tag will be created if
+ * the Text property is set for this control.
+ *
+ * @return bool wether this control needs a surrounding span tag
+ */
+ protected function getSpanNeeded() {
+ return $this->getText()!=='';
+ }
+
/**
* Renders a label beside the checkbox.
* @param THtmlWriter the writer for the rendering purpose
@@ -500,4 +511,4 @@ class TTextAlign extends TEnumerable const Right='Right';
}
-?>
\ No newline at end of file +?>
|