Jiew Meng
Jiew Meng

Reputation: 88197

Setting CSS Class/Styles using Zend Framework HtmlTag View Helper

I am trying to add CSS Class & inline style to a form element's/decorator. I tried

$this->addElement('text', 'honeypot', array(
    ...
    'decorators' => array(
        'ViewHelper',
        'Label',
        array('HtmlTag', array('tag' => 'p', 'class' => 'honeypot', 'style' => 'display: none'))
    )
));

But the <p> didn't have the class & style attributes attached

Upvotes: 1

Views: 1586

Answers (1)

Phil
Phil

Reputation: 164795

Works fine for me. Are you resetting the element decorators later on using Zend_Form::setElementDecorators() or something similar?

alt text

FYI, you should probably have a semi-colon after your inline style rule, eg

'style' => 'display: none;'

Upvotes: 1

Related Questions