';
return $label;
}
return parent::toHtml().$label;
}
/**
* Returns whether radio button is checked
*
* @return string
* @since 1.0
*/
public function getChecked()
{
return $this->getAttribute('checked');
}
/**
* Returns the value of field without HTML tags
*
* @return string
* @since 1.0
*/
public function getFrozenHtml()
{
if ($this->getChecked()) {
return ' (x)'.
$this->_getPersistantData();
}
return ' ( )';
}
/**
* Returns the radio text
*
* @return string
* @since 1.1
* @access public
*/
public function getText()
{
return $this->_text;
}
/**
* Sets the radio text
*
* @param string $text Text to display near the radio button
*
* @return void
* @since 1.1
* @access public
*/
public function setText($text)
{
$this->_text = $text;
}
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
* @param string $event Name of event
* @param mixed $arg event arguments
* @param object &$caller calling object
*
* @return void
* @since 1.0
* @access public
*/
public function onQuickFormEvent($event, $arg, &$caller)
{
switch ($event) {
case 'updateValue':
// constant values override both default and submitted ones
// default values are overriden by submitted
$value = $this->_findValue($caller->_constantValues);
if (null === $value) {
$value = $this->_findValue($caller->_submitValues);
if (null === $value) {
$value = $this->_findValue($caller->_defaultValues);
}
}
if (!is_null($value) && $value == $this->getValue()) {
$this->setChecked(true);
} else {
$this->setChecked(false);
}
break;
case 'setGroupValue':
if ($arg == $this->getValue()) {
$this->setChecked(true);
} else {
$this->setChecked(false);
}
break;
default:
parent::onQuickFormEvent($event, $arg, $caller);
}
return true;
}
/**
* Sets whether radio button is checked
*
* @param bool $checked Whether the field is checked or not
*
* @return void
* @since 1.0
* @access public
*/
public function setChecked($checked)
{
if (!$checked) {
$this->removeAttribute('checked');
} else {
$this->updateAttributes(array('checked' => 'checked'));
}
}
/**
* Returns the value attribute if the radio is checked, null if it is not
*/
public function exportValue(&$submitValues, $assoc = false)
{
$value = $this->_findValue($submitValues);
if (null === $value) {
$value = $this->getChecked() ? $this->getValue() : null;
} elseif ($value != $this->getValue()) {
$value = null;
}
return $this->_prepareValue($value, $assoc);
}
/**
* @return null
*/
public function getColumnsSize()
{
return $this->columnsSize;
}
}