2

如何从多个复选框选项中获取多个值数据?以下是我可以选择多个值的复选框 html 代码

<li class='voteable-attribute off clearfix'>
            <label class='primary formField'>Parking:
            </label>
                    <div class='inputFields ieSucks'>
            <div class='thereisonlybool'>
                <label for='av_box:BusinessParking:valet'>
                    <input type='checkbox' id='av_box:BusinessParking:valet' name='BusinessParking_valet' value='1'>
                    Valet
                </label>
            </div>
            <div class='thereisonlybool'>
                <label for='av_box:BusinessParking:garage'>
                    <input type='checkbox' id='av_box:BusinessParking:garage' name='BusinessParking_garage' value='1'>
                    Garage
                </label>
            </div>
            <div class='thereisonlybool'>
                <label for='av_box:BusinessParking:street'>
                    <input type='checkbox' id='av_box:BusinessParking:street' name='BusinessParking_street' value='1'>
                    Street
                </label>
            </div>
            <div class='thereisonlybool'>
                <label for='av_box:BusinessParking:lot'>
                    <input type='checkbox' id='av_box:BusinessParking:lot' name='BusinessParking_lot' value='1'>
                    Private Lot
                </label>
            </div>
            <div class='thereisonlybool'>
                <label for='av_box:BusinessParking:validated'>
                    <input type='checkbox' id='av_box:BusinessParking:validated' name='BusinessParking_validated' value='1'>
                    Validated
                </label>
            </div>
    </div>


        </li>

从 zend 控制器我可以访问单个值,如下所示:

$data1 = $this->_getParam('input_name')

但是在这种情况下有多个值,我怎样才能在 zend 控制器中获取这个多个值并将其存储在数组中并保存在 db.Thanks

4

2 回答 2

0

您必须创建一个名为BusinessParking[]的元素。

意思是像数组一样创建这个复选框。现在,当您获得价值控制器时,您就会得到想要的东西。

于 2013-02-13T07:34:47.777 回答
0

将html页面创建为:

<input type="hidden" name="id[]" value="<?php echo $value[i] ?>"/>

注意name="id[]",这就是诀窍。现在在 Zend 中,您可以获得如下值:

$array = $this->getRequest()->getParam("id");
于 2014-01-30T21:54:49.993 回答