cakephp复选框多个选择只发送最后选择的值复选框 [英] cakephp checkbox multiple select just sends the value of last selected checkbox
本文介绍了cakephp复选框多个选择只发送最后选择的值复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我没有获得所有复选框的值。它只是给我最后选择的值复选框
I am not getting the value of all the checkboxes selected. It just gives me the value of last selected checkbox
这里是代码
foreach($apps as $app){
echo $this->Form->input('Application.id', array('type'=>'checkbox','multiple' => 'checkbox' , 'id'=>$app['Application']['description'], 'div'=>false,'type'=>'checkbox','value' => $app['Application']['description'],'label'=>$app['Application']['description']));
}
获取最后一个复选框LASTCHECKBOX
and on submit I get the very last checkbox which is LASTCHECKBOX
object(CakeRequest) {
params => array(
'plugin' => null,
'controller' => 'groups',
'action' => 'add',
'named' => array(),
'pass' => array()
)
data => array(
'Application' => array(
'id' => 'LASTCHECKBOX'
)
)
query => array()
url => 'groups/add'
base => ''
webroot => '/'
here => '/groups/add'
}
推荐答案
我认为这是因为价值。
在你的情况下使用options=> array(1,2,3)
你最好不要在视图中设置值,默认值等。
使用控制器动作设置默认值。
比它应该工作得很好。
you should better never set value, default or anything like that in the view. use the controller action to set a default. than it should work fine.
if ($this->request->isPost()) {
} else {
$this->request->data['Model']['fieldname'] = 'defaultvalue';
}
这篇关于cakephp复选框多个选择只发送最后选择的值复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文