Hello,
I am building a form that uses the multiCheckbox form element. I need to add
class names to specific checkboxes for javascript purposes. Is there a way
to do that?

I tried this, but it ended up adding the class name "foo" to all of the
checkboxes:

$this->addElement('multiCheckbox', 'publishers', array(
    'label'    => 'Publishers',
    'multiOptions' => array(/* ... */),
    'attribs'  => array(
        'class' => 'foo'
    )
));

I thought maybe I could pass in an associative array of value => classname
but that ended up adding all of the class names to all of the checkboxes:

$this->addElement('multiCheckbox', 'publishers', array(
    'label'    => 'Publishers',
    'multiOptions' => array(/* ... */),
    'attribs'  => array(
        'class' => array(
            1       => 'foo',
            7       => 'bar'
        )
    )
));

I've also tried adding it to the label, but the result was the same (all
class names were added to all labels)

$this->addElement('multiCheckbox', 'publishers', array(
    'label'    => 'Publishers',
    'multiOptions' => array(/* ... */),
    'attribs'  => array(
        'label_class' => array(
            1       => 'foo',
            7       => 'bar'
        )
    )
));

Any ideas on how to accomplish this? I wouldn't mind adding the classname to
the label if necessary. Thanks!

--
Hector

Reply via email to