zend-frameworkzend-form

Zend 1 radio option as image


I want to show images as option label using Zend_Form_Element_Radio (Zend1). Something like this:

$element->setMultiOptions(array(1=> '<img src="x.jpg">'));

The expected output is to show the Image as the Label of the option. What would be the best way to do this.

I was able to disable escaping the Label of the Radio element by this line

$form->$elName->getDecorator('label')->setOption('escape', false);

But, looking for a way to achieve this effect for specific options.


Solution

  • You need to set escape=false on the element, not just the decorator. Something like

    $el = new Zend_Form_Element_Radio('radio', array(
        'options' => $options,
        'escape' => false, // <- this is the line
    ));