如何发布在CI中未选中的复选框?

时间:2017-10-13 06:01:14

标签: php jquery html codeigniter checkbox

在这里,我的多个复选框的html视图:

enter image description here

复选框的Html如下所示

适用于A_I复选框

<input type="hidden" name="auto_number[]" id="auto_numberhidden" value="0" />
<input type="checkbox" name="auto_number[]" id="auto_number" value="1" />

不显示在表单复选框

<input type="hidden" name="not_show_in_form[]" id="not_show_in_formhidden" value="0" />
<input type="checkbox" name="not_show_in_form[]" id="not_show_in_form" value="1" />

以下是添加表格数据的CI功能:

if ($this->form_validation->run() == TRUE) {

            $name_col = $this->input->post('name_col');
            $type_col = $this->input->post('type_col');
            $length_values_col = $this->input->post('length_values_col');
            $index_col = $this->input->post('index_col');
            $auto_number = $this->input->post('auto_number');
            $not_show_in_form = $this->input->post('not_show_in_form');
            $createTable = $post = array();
            for ($i = 0; $i < count($name_col); $i++) {
                $createTable['fields'][] = array(
                    'name_field' => $name_col[$i],
                    'type_field' => $type_col[$i],
                    'length_field' => $length_values_col[$i],
                    'index_field' => $index_col[$i],
                    'auto_field' => $auto_number[$i],
                    'not_show_in_form' => $not_show_in_form[$i]
                );
            }
            echo '<pre>';
            print_r($createTable);die;
}

当我提交表单时,它会给我一个表格数组:

    Array
(
    [fields] => Array
        (
            [0] => Array
                (
                    [name_field] => id
                    [type_field] => INT
                    [length_field] => 11
                    [index_field] => PRIMARY
                    [auto_field] => 0
                    [not_show_in_form] => 0
                )

            [1] => Array
                (
                    [name_field] => name
                    [type_field] => VARCHAR
                    [length_field] => 20
                    [index_field] => 
                    [auto_field] => 1
                    [not_show_in_form] => 1
                )

            [2] => Array
                (
                    [name_field] => gender
                    [type_field] => VARCHAR
                    [length_field] => 10
                    [index_field] => 
                    [auto_field] => 0
                    [not_show_in_form] => 0
                )

            [3] => Array
                (
                    [name_field] => created_date
                    [type_field] => DATE
                    [length_field] => 
                    [index_field] => 
                    [auto_field] => 0
                    [not_show_in_form] => 0
                )

        )

)

问题:

此处, id 字段有两个检查值,即A_I和非显示IN表单, created_date 只有不显示IN表单。 根据我的形式我的数组如下,但它给我上面的数组。

Array
(
    [fields] => Array
        (
            [0] => Array
                (
                    [name_field] => id
                    [type_field] => INT
                    [length_field] => 11
                    [index_field] => PRIMARY
                    [auto_field] => 1
                    [not_show_in_form] => 1
                )

            [1] => Array
                (
                    [name_field] => name
                    [type_field] => VARCHAR
                    [length_field] => 20
                    [index_field] => 
                    [auto_field] => 0
                    [not_show_in_form] => 0
                )

            [2] => Array
                (
                    [name_field] => gender
                    [type_field] => VARCHAR
                    [length_field] => 10
                    [index_field] => 
                    [auto_field] => 0
                    [not_show_in_form] => 0
                )

            [3] => Array
                (
                    [name_field] => created_date
                    [type_field] => DATE
                    [length_field] => 
                    [index_field] => 
                    [auto_field] => 0
                    [not_show_in_form] => 1
                )

        )

)

如何修复我的阵列。

感谢您的帮助。

0 个答案:

没有答案