1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
class sfWidgetFormSelectMyRadio extends sfWidgetFormSelectRadio
{
/**
* @desc Redéfinition de la méthode parente formatChoices
*
* @see sfWidgetFormSelectRadio
*/
protected function formatChoices($name, $value, $choices, $attributes)
{
$inputs = array();
foreach ($choices as $key => $option)
{
$baseAttributes = array(
'name' => substr($name, 0, -2),
'type' => 'radio',
'value' => self::escapeOnce($key),
'id' => $id = $this->generateId($name, self::escapeOnce($key)),
);
if (strval($key) == strval($value === false ? 0 : $value))
{
$baseAttributes['checked'] = 'checked';
}
$inputs[$id] = array(
'input' => $this->renderTag('input', array_merge($baseAttributes, $attributes)),
'label' => $this->renderTag("img", array('value' => "path_to_img")),
);
}
return call_user_func($this->getOption('formatter'), $this, $inputs);
}
} |
Partager