Zend multiCheckbox default values bug

你。 提交于 2019-12-24 07:38:51

问题


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:


$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(


来源:https://stackoverflow.com/questions/23476847/zend-multicheckbox-default-values-bug

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!