*/
class Varien_Data_Form_Element_Radios extends Varien_Data_Form_Element_Abstract
{
public function __construct($attributes=array())
{
parent::__construct($attributes);
$this->setType('radios');
}
public function getSeparator()
{
$separator = $this->getData('separator');
if (is_null($separator)) {
$separator = ' ';
}
return $separator;
}
public function getElementHtml()
{
$html = '';
$value = $this->getValue();
if ($values = $this->getValues()) {
foreach ($values as $option) {
$html.= $this->_optionToHtml($option, $value);
}
}
$html.= $this->getAfterElementHtml();
return $html;
}
protected function _optionToHtml($option, $selected)
{
$html = 'serialize(array('name', 'class', 'style'));
if (is_array($option)) {
$html.= 'value="'.$this->_escape($option['value']).'" id="'.$this->getHtmlId().$option['value'].'"';
if ($option['value'] == $selected) {
$html.= ' checked="checked"';
}
$html.= ' />';
$html.= '';
}
elseif ($option instanceof Varien_Object) {
$html.= 'id="'.$this->getHtmlId().$option->getValue().'"'.$option->serialize(array('label', 'title', 'value', 'class', 'style'));
if (in_array($option->getValue(), $selected)) {
$html.= ' checked="checked"';
}
$html.= ' />';
$html.= '';
}
$html.= $this->getSeparator() . "\n";
return $html;
}
}