Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php zend多复选框窗体控制器_Php_Zend Framework_Zend Form - Fatal编程技术网

Php zend多复选框窗体控制器

Php zend多复选框窗体控制器,php,zend-framework,zend-form,Php,Zend Framework,Zend Form,我用Multicheckbox做了表单,插入或更新时效果很好,但我的问题是如何填充数据库中选中的所有多框这是代码,但它不显示选中的复选框 $id = (int) $this->_request->getParam('id'); //The incoming request $request = $this->getRequest(); //initialize form $form = new Admin_Form_DownFoote

我用Multicheckbox做了表单,插入或更新时效果很好,但我的问题是如何填充数据库中选中的所有多框这是代码,但它不显示选中的复选框

      $id = (int) $this->_request->getParam('id');
    //The incoming request
    $request = $this->getRequest();
    //initialize form
    $form = new Admin_Form_DownFooterTab();
    //instance of db
    $db = Zend_Db_Table::getDefaultAdapter();

    if ($this->getRequest()->isPost()) {
        if ($form->isValid($request->getPost())) {
            if (isset($id) && $id != "") {
                $gettag = $form->getValue('tag_id');
                $gettags = count($gettag);
                try {
                    //shift the orders to
                    $select = $db->select()->from(array('t' => 'tab'), array('t.id',
                                't.title',
                                't.tab_position',
                                't.order',
                                't.is_active',
                                't.is_deleted'))->where('id = ?', $id);
                    $currentTab = $db->fetchRow($select);

                    $var3 = array('tab.order' => new Zend_Db_Expr('tab.order - 1'));
                    $var4 = array('tab.order >= ' . $currentTab['order'], 'is_active=1', 'is_deleted=0', 'tab_position=4');
                    $db->update('tab', $var3, $var4);



                    $var = array('tab.order' => new Zend_Db_Expr('tab.order + 1'));
                    $var2 = array('tab.order >= ' . $form->getValue('order'), 'is_active=1', 'is_deleted=0', 'tab_position=4');
                    $db->update('tab', $var, $var2);
                    $db->delete('tab_tag', array('tab_id = ?' => $id));
                    foreach ($gettag as $value) {

                        $db->insert('tab_tag',
                                array(
                                    'tag_id' => $value,
                                    'tab_id' => $id
                        ));
                    }
                    $db->update('tab', array(
                        'title' => $form->getValue('title'),
                        'body' => $form->getValue('body'),
                        'is_active' => $form->getValue('is_active'),
                        'banner_link' => $form->getValue('banner_link'),
                        'tab_path' => $form->getValue('tab_path'),
                        'link_open' => $form->getValue('link_open'),
                        'tab_position' => $form->getValue('tab_position'),
                        'tab_parent' => $form->getValue('tab_parent')
                            ),
                            array('id =?' => $id));
                    $this->flash('Tab Updated', 'admin/tab');
                } catch (Exception $e) {
                    $this->flash($e->getMessage(), 'admin/tab');
                }
            } else {
                try {
                    $formValues = $form->getValues();
                    $formValues['created_by'] = 1;
                    $formValues['created_date'] = date('Y/m/d H:i:s');
                    $formValues['is_deleted'] = 0;

                    $var = array('tab.order' => new Zend_Db_Expr('tab.order + 1'));
                    $var2 = array('tab.order >= ' . $form->getValue('order'), 'is_active=1', 'is_deleted=0', 'tab_position=4');
                    $db->update('tab', $var, $var2);


                    foreach ($gettag as $value) {

                        $db->insert('tab_tag',
                                array(
                                    'tag_id' => $value,
                                    'tab_id' => $id
                        ));
                    }
                    $db->insert('tab', array(
                        'title' => $form->getValue('title'),
                        'body' => $form->getValue('body'),
                        'is_active' => $form->getValue('is_active'),
                        'banner_link' => $form->getValue('banner_link'),
                        'tab_path' => $form->getValue('tab_path'),
                        'link_open' => $form->getValue('link_open'),
                        'tab_position' => $form->getValue('tab_position'),
                        'tab_parent' => $form->getValue('tab_parent')
                    ));
                    $this->flash('Tab inserted', 'admin/tab');
                } catch (Exception $e) {
                    $this->flash($e->getMessage(), 'admin/tab');
                }
            }
        }
    }
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */


    if (isset($id) && $id != "") {
        $values = $db->fetchRow("SELECT * FROM tab WHERE id = ?", $id);
        $form->populate($values);
    }

    $this->view->form = $form;
}

    $ddlCat_parent->setMultiOptions($cats);
    $this->view->form = $form;
}