summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TLabel.php
diff options
context:
space:
mode:
authorxue <>2006-09-04 19:15:47 +0000
committerxue <>2006-09-04 19:15:47 +0000
commit56fee292c37e162c03fab9eeadd6a8b9ab85c251 (patch)
tree923510b93c707868098ae4e5f404eb3766a59553 /framework/Web/UI/WebControls/TLabel.php
parentb107cad91733d4a2a80f42cdbaab41a4f7b41c9d (diff)
merge from 3.0 branch till 1387
Diffstat (limited to 'framework/Web/UI/WebControls/TLabel.php')
-rw-r--r--framework/Web/UI/WebControls/TLabel.php27
1 files changed, 25 insertions, 2 deletions
diff --git a/framework/Web/UI/WebControls/TLabel.php b/framework/Web/UI/WebControls/TLabel.php
index a7a25eef..65517fc9 100644
--- a/framework/Web/UI/WebControls/TLabel.php
+++ b/framework/Web/UI/WebControls/TLabel.php
@@ -20,6 +20,7 @@
* To use TLabel as a form label, associate it with a control by setting the
* {@link setForControl ForControl} property.
* The associated control must be locatable within the label's naming container.
+ * If the associated control is not visible, the label will not be rendered, either.
*
* Note, {@link setText Text} will NOT be encoded for rendering.
* Make sure it does not contain dangerous characters that you want to avoid.
@@ -31,6 +32,8 @@
*/
class TLabel extends TWebControl
{
+ private $_forControl='';
+
/**
* @return string tag name of the label, returns 'label' if there is an associated control, 'span' otherwise.
*/
@@ -46,14 +49,34 @@ class TLabel extends TWebControl
*/
protected function addAttributesToRender($writer)
{
+ if($this->_forControl!=='')
+ $writer->addAttribute('for',$this->_forControl);
+ parent::addAttributesToRender($writer);
+ }
+
+ /**
+ * Renders the label.
+ * It overrides the parent implementation by checking if an associated
+ * control is visible or not. If not, the label will not be rendered.
+ * @param THtmlWriter writer
+ */
+ public function render($writer)
+ {
if(($aid=$this->getForControl())!=='')
{
if($control=$this->findControl($aid))
- $writer->addAttribute('for',$control->getClientID());
+ {
+ if($control->getVisible(true))
+ {
+ $this->_forControl=$control->getClientID();
+ parent::render($writer);
+ }
+ }
else
throw new TInvalidDataValueException('label_associatedcontrol_invalid',$aid);
}
- parent::addAttributesToRender($writer);
+ else
+ parent::render($writer);
}
/**