cakephp复选框显示额外的隐藏字段 [英] cakephp checkbox is showing extra hidden field

查看:148
本文介绍了cakephp复选框显示额外的隐藏字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

foreach($apps as $app){


        echo $this->Form->input('Application', array('type'=>'checkbox', 'id'=>$app['Application']['description'], 'div'=>false,'type'=>'checkbox','value' => $app['Application']['description'],'label'=>$app['Application']['description']));



    }


<div class="checkboxes"> 
    <input type="hidden" name="data[Group][Application]" id="GG_" value="0"/><input type="checkbox" name="data[Group][Application]"  id="GG" value="GG"/><label for="GG">GG</label><input type="hidden" name="data[Group][Application]" id="BS_" value="0"/><input type="checkbox" name="data[Group][Application]"  id="BS" value="BS"/><label for="BS">BS</label>  <div>
</div>
    <input type="hidden" name="data[Group][Grant]" id="GroupGrant_" value="0"/><input type="checkbox" name="data[Group][Grant]"  style="float: left; display: inline" value="Edit Weather" id="GroupGrant"/><label for="GroupGrant">Edit Weather</label><input type="hidden" name="data[Group][Grant]" id="GroupGrant_" value="0"/><input type="checkbox" name="data[Group][Grant]"  style="float: left; display: inline" value="Edit Traffic" id="GroupGrant"/><label for="GroupGrant">Edit </label>       




        </div>

不知道隐藏字段来自哪里。
感谢

not sure where the hidden field is coming from. thanks

推荐答案

这是一个蛋糕回退,以防你不选择复选框,为验证跳跃。
在这种情况下php不会提交任何此字段(甚至一个空字符串)。因此蛋糕找到了解决这个问题的聪明的解决方法。

this is a cake fallback in case you don't select the checkbox and post the form in order for the validation to jump in. in this case php would not submit anything for this field (not even an empty string). therefore cake has found a smart workaround to overcome this issue.

类似的东西与单选按钮btw。

similar thing with radio buttons btw.

这篇关于cakephp复选框显示额外的隐藏字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆