Subscript or Superscript text within a Zend Form l

2019-05-07 04:23发布

I would like to include subscript text in a Zend_Form_Element's label, and it doesn't seem to be working:

 $zend_form_element->setLabel('Label <sub>x</sub>');

Is there anything I can do to get it to output properly without having to manually write the form on the view page? Thanks for the help,

Dave

5条回答
贼婆χ
2楼-- · 2019-05-07 05:01

From @fireeyedboy's answer, you can also do the following directly in your Zend_Form:

$this->addElement(
'radio',
'name',
array(
    /* more settings */
    'attribs'   => array(
        'escape' => FALSE
    )
));
查看更多
我命由我不由天
3楼-- · 2019-05-07 05:02

Here is the right way to do it:

$zend_form_element->addDecorator('Label', аrray('escape'=>false));

from: http://forums.zend.com/viewtopic.php?f=69&t=5706

查看更多
仙女界的扛把子
4楼-- · 2019-05-07 05:03

You can also it it the following way:

$radioElement = new Zend_Form_Element_Checkbox('formelement_0');
$radioElement->setLabel('Do you accept the <a href="#">Terms &amp; Conditions</a>?');
$radioElement->getDecorator('Label')->setOption('escape', false);
查看更多
看我几分像从前
5楼-- · 2019-05-07 05:04

Try:

$zend_form_element->setAttribs( array( 'escape' => false ) )
                  ->setLabel( 'Label <sub>x</sub>' );

Or the singular:

$zend_form_element->setAttrib( 'escape', false )
                  ->setLabel( 'Label <sub>x</sub>' );
查看更多
走好不送
6楼-- · 2019-05-07 05:07

I would say that best way is to get actual decorator from element and then set escape option, not to add new decorator:

$zend_form_element->getDecorator('Label')->setOption('escape',false);
查看更多
登录 后发表回答