Menu

#167 renderBody of TDropDownList

v2.0
open
nobody
components (68)
5
2006-03-16
2006-03-16
Anonymous
No

renderBody of TDropDownList does not render additional
attributes. The code below incorporates some code from
TCheckBoxList which takes care of all the standard
attributes.

protected function renderBody()
{
$content="\n";
$formatString = $this->getDataTextFormatString();
foreach($this->getItems() as $item)
{
$text=$item->getText();
if(strlen($formatString))
$text=sprintf($formatString,$text);
if($this->isEncodeText())
$text=pradoEncodeData($text);
$value=$item->getValue();

$attr = $item->getAttributesToRender();
if(isset($attr['id'])) unset($attr['id']);
if(isset($attr['value'])) unset($attr['value']);
$attr = $item->renderAttributes($attr);

if($item->isSelected())
$content.='<option value="'.$value.'"
selected="selected" '.$attr.'>'.$text.'</option>'."\n";
else
$content.='<option value="'.$value.'"
'.$attr.'>'.$text.'</option>'."\n";
}
return $content;
}

Discussion


Log in to post a comment.