summaryrefslogtreecommitdiff
path: root/framework/Web/UI
diff options
context:
space:
mode:
authorxue <>2006-09-02 12:00:12 +0000
committerxue <>2006-09-02 12:00:12 +0000
commit4cf72b151eba3357da19d670c8cccd49851a5fbe (patch)
tree154e5060ba746cfa772d2563a1b1989cb587aff8 /framework/Web/UI
parent32feb309dc59ca50757431d627db7437c0e29073 (diff)
Fixed #356.
Diffstat (limited to 'framework/Web/UI')
-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);
}
/**