Welcome Guest, Not a member yet? Register   Sign In
can you show me how match routes dont work in this case>
#1

(This post was last modified: 07-19-2024, 07:32 PM by startup.)

today i test matches routes in codeigniter 4.5.3 but it don't work, someone can show me?
routes
PHP Code:
$routes->match(['get','post'],'vnadmin/camera_category/addCate','\Modules\Admin\Cam\Controllers\CamController::addCate'); 

controller
PHP Code:
public function addCate(){
        //$this->mAuth->check();
        $data['Method'] = base_url('vnadmin/camera_category/addCate');
        $data['max_sort']=$this->m_cam->SelectMax('categories','sort')+1;
        $data['proshow_cate'] = $this->m_cam->getList('categories');
        $data['btn_name']='Thêm';
        $data['headerTitle'] = "Thêm danh mục cam";

        if($this->request->getMethod() == "post"){
            echo $this->request->getMethod();
            exit();
                $name $this->request->getPost('name');
                $parent $this->request->getPost('parent');
                $description $this->request->getPost('description');
                $keyword $this->request->getPost('keyword');
                //image goc
                
                $cate 
= [  'name'        => 'hoclai',
                            'slug'        => "hoc-lai",          
                
];

                $this->m_cam->Add('categories'$cate);
                return redirect()->to(base_url('/vnadmin/danh-muc-camera'));
        }
        echo view('admin/header'$data);
        echo view('admin/post_cam_cate_add'$data);
        echo view('admin/footer');
    

view
PHP Code:
<form class="form-horizontal" role="form" name ="form1" id="form1" method="post" action="<?php echo $Method; ?>" enctype="multipart/form-data" >
                        <input type="hidden" name="edit" value="<?=@$edit->id;?>">
                        <div class="form-group">
                            <label for="listcate" class="col-lg-2 control-label">Tên danh mục:</label>
                            <div class="col-lg-5">
                                <input type="text" class="form-control input-sm " name="name" value="<?=@$edit->name;?>" placeholder="Tên danh mục"  />
                            </div>
                            <div class="col-lg-1">
                                <label >
                                    <input type="checkbox" value="1" name="hot" <?php echo  @$edit->hot==1?'checked':'' ?>>
                                    <?php echo _title_cam_cate_hot?>
                                </label>
                                </div>
                                <div class="col-lg-1">
                                <label >
                                    <input type="checkbox" value="1" name="menu_hide" <?php echo  @$edit->menu_hide==1?'checked':'' ?>>
                                    <?php echo _title_cam_menu_hide?>
                                </label>
                                </div>
                                <div class="col-lg-1">
                                <label >
                                    <input type="checkbox" value="1" name="hide" <?php echo  @$edit->hide==1?'checked':'' ?>>
                                    <?php echo _title_cam_hide?>
                                </label>
                            </div>

                        </div>
                        <div class="form-group">
                            <label for="inputEmail1" class="col-lg-2 control-label">Danh mục cha:</label>
                            <div class="col-lg-5">
                                <select name="parent" class="form-control input-sm">
                                    <option value="0">root</option>
                                    <?php view_product_cate_select($proshow_cate,0,'', @$edit->parent_id);?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label  class="col-lg-2 control-label">Thứ tự:</label>
                            <div class="col-lg-2">
                                <input type="number" name="sort" class="form-control input-sm" value="<?php echo @$edit->order;?>" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputEmail1" class="col-lg-2 control-label">Mô Tả:</label>
                            <div class="col-lg-5">
                            <textarea name="description" class="form-control" id="description" placeholder="Mô tả"><?=@$edit->description;?></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputEmail1" class="col-lg-2 control-label">Keywords:</label>
                            <div class="col-lg-5">
                            <textarea name="keyword" class="form-control" id="keyword" placeholder="Mô tả"><?=@$edit->keyword;?></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputEmail1" class="col-lg-2 control-label">Image:</label>
                            <div class="col-lg-5">
                            <input type="file" name="userfile" size="20" class="form-control" >
                            </div>
                        </div>
                        <div class="text-center">
                            <button type="submit" class="btn btn-success btn-sm" name="addcate"><i class="fa fa-check"></i> <?=$btn_name;?></button>
                        </div>
                    </form> 

this code can go to  page addCate but it dont get post data
Reply


Messages In This Thread
can you show me how match routes dont work in this case> - by startup - 07-19-2024, 07:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB