Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add custom HTML Tag with Zend Form Description

Consider I would like to display

Checkbox, Checkbox label and an image there after.

How can I create a view for the same using Zend Engine Form

I tried as follows

    $this->addElement(
            'Checkbox',
            "$key",
            array(
             'label'=>$value,
                'checkedValue' => "$key",
                'uncheckedValue' => '',
                'checked' => true,
             'disabled' => false,
          )
        );

     $element = $this->getElement($key);         


       $element->setDecorators(
   array(
     'ViewHelper',
     array('Label', array('tag' => 'dt', 'class'=>'hidden')),
     array('Description',array('escape'=>false,'tag'=>' span')), //escape false because I want html output
    )
   );

     $element->setDescription('<img name="help_'.$key.'" id="help_'.$key.'" src="/application/modules/User/externals/images/what-is-this.gif"/>');

$element->setDescription('<img name="help_'.$key.'" id="help_'.$key.'" src="/application/modules/User/externals/images/what-is-this.gif"/>');

But which showing checkbox, description image and checkbox label as superscript.

Any help please

like image 454
Aadi Avatar asked Dec 02 '10 05:12

Aadi


2 Answers

$element->getDecorator('Description')->setEscape(false);

This will prevent escaping description content.

like image 109
Pavel Galaton Avatar answered Nov 06 '22 21:11

Pavel Galaton


Check out the AnyMarkup Decorator.

You can add that decorator into your element decorator list, specifying the markup for the image with an APPEND position.

like image 25
David Weinraub Avatar answered Nov 06 '22 19:11

David Weinraub