Question

I don't know. Simply I don't know. Why does the second codeblock work and check the checkboxes by default, but the first block isn't?

I need to pre-check bitmask flags and I can't/don't want to append strings or something.

    // THIS isn't working?!!

    $test1 = array(
        2 => 'tomato',
        4 => 'bitmask problem'
    );
    $test2 = array(2, 4);

    $form->addElement('multiCheckbox', 'flags', array(
            'label' => 'Flags',
            'value' => $test2,
            'multiOptions' => $test1,
        )
    );

    // THIS IS WORKING:

    $form->addElement ( 
        'multiCheckbox', 'servers2', 
        array (
            'label' => 'test',
            'value' => array('a', 'b'), // select these 2 values
            'multiOptions' => array(
                        'a' => 'aaaaa',
                        'b' => 'aaaaa',
                        'c' => 'aaaa',
                        )
        )
    );
Was it helpful?

Solution

$form->addElement('multiCheckbox', 'flags', array(

This is causing the error. flags is kinda reserved word in Zend I guess. But I didn't get an error message and I have no other form elements or even variables called flags.

When I rename this, it works!

$form->addElement('multiCheckbox', 'matchingFlags', array(
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top