9

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

2 Answers 2

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

This will prevent escaping description content.

Sign up to request clarification or add additional context in comments.

1 Comment

Also useful to know that if you'd like to unescape the description set directly on the form itself ($this), you can use $this->getDecorator('Description')->setOption('escape', false);
2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.