Zend multiCheckbox default values bug

2019-07-30 11:13发布

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',
                        )
        )
    );

1条回答
老娘就宠你
2楼-- · 2019-07-30 11:26
$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(
查看更多
登录 后发表回答