diff options
author | xue <> | 2006-07-21 18:12:36 +0000 |
---|---|---|
committer | xue <> | 2006-07-21 18:12:36 +0000 |
commit | c67ad6b37e8f1a02d85ca5170341b22ebd6bf34b (patch) | |
tree | 5b4a9f73146f04e74679f7893d4cc31af8a37b45 /framework/Web/UI/WebControls/TListControl.php | |
parent | aff2407a4507713453deb274837ab2bbf39303b2 (diff) |
Fixed #263.
Diffstat (limited to 'framework/Web/UI/WebControls/TListControl.php')
-rw-r--r-- | framework/Web/UI/WebControls/TListControl.php | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/framework/Web/UI/WebControls/TListControl.php b/framework/Web/UI/WebControls/TListControl.php index 7cdfc727..d5949dde 100644 --- a/framework/Web/UI/WebControls/TListControl.php +++ b/framework/Web/UI/WebControls/TListControl.php @@ -621,24 +621,53 @@ abstract class TListControl extends TDataBoundControl if($this->_items)
{
$writer->writeLine();
+ $previousGroup=null;
foreach($this->_items as $item)
{
if($item->getEnabled())
{
- if($item->getSelected())
- $writer->addAttribute('selected','selected');
- $writer->addAttribute('value',$item->getValue());
if($item->getHasAttributes())
{
+ $group=$item->getAttributes()->remove('Group');
+ if($group!==$previousGroup)
+ {
+ if($previousGroup!==null)
+ {
+ $writer->renderEndTag();
+ $writer->writeLine();
+ $previousGroup=null;
+ }
+ if($group!==null)
+ {
+ $writer->addAttribute('label',$group);
+ $writer->renderBeginTag('optgroup');
+ $writer->writeLine();
+ $previousGroup=$group;
+ }
+ }
foreach($item->getAttributes() as $name=>$value)
$writer->addAttribute($name,$value);
}
+ else if($previousGroup!==null)
+ {
+ $writer->renderEndTag();
+ $writer->writeLine();
+ $previousGroup=null;
+ }
+ if($item->getSelected())
+ $writer->addAttribute('selected','selected');
+ $writer->addAttribute('value',$item->getValue());
$writer->renderBeginTag('option');
$writer->write(THttpUtility::htmlEncode($item->getText()));
$writer->renderEndTag();
$writer->writeLine();
}
}
+ if($previousGroup!==null)
+ {
+ $writer->renderEndTag();
+ $writer->writeLine();
+ }
}
}
|