问题
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