本文介绍了Zend multiCheckbox默认值bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道。只是我不知道。为什么第二个代码块工作,默认检查复选框,但第一个块不是?
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',
)
)
);
推荐答案
$form->addElement('multiCheckbox', 'flags', array(
flags
是Zend中的一个保留字我想,但我没有得到一个错误消息,我没有其他表单元素,甚至变量 flags
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(
这篇关于Zend multiCheckbox默认值bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!