From 3ec0ec6275b1ab8a95b2696febcdd0284732fce2 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 16 Mar 2006 22:04:31 +0000 Subject: Added findControlsByID. --- framework/Web/UI/TControl.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'framework/Web') diff --git a/framework/Web/UI/TControl.php b/framework/Web/UI/TControl.php index 4b5696bd..21482b0a 100644 --- a/framework/Web/UI/TControl.php +++ b/framework/Web/UI/TControl.php @@ -896,6 +896,33 @@ class TControl extends TApplicationComponent return $controls; } + /** + * Finds all child and grand-child controls with the specified ID. + * Note, this method is different from {@link findControl} in that + * it searches through all controls that have this control as the ancestor + * while {@link findcontrol} only searches through controls that have this + * control as the direct naming container. + * @param string the ID being looked for + * @return array list of controls found + */ + public function findControlsByID($id) + { + $controls=array(); + if($this->getHasControls()) + { + foreach($this->_rf[self::RF_CONTROLS] as $control) + { + if($control instanceof TControl) + { + if($control->_id===$id) + $controls[]=$control; + $controls=array_merge($controls,$control->findControlsByID($id)); + } + } + } + return $controls; + } + /** * Resets the control as a naming container. * Only framework developers should use this method. -- cgit v1.2.3