2014-11-01 62 views
0

控制器我想根據控制器重定向表單提交明智如何調用兩個不同的控制器一種觀點認爲,將用戶重定向根據笨

function list_mapdemand($id) 
{ 
    $data['titlte'] = "mapdemand"; 
    $data['demand_id'] = $id; 
    $data['get_map_demand'] = $this->demands_model->get_exist_demand_map_from_prospect($id); 
    //print_r($data['get_map_demand']); 
    //exit; 
    //print_r($data['get_map_candidate']); 
    $data['get_mapped_demand'] = $this->demands_model->get_exist_prospective_candidate($id); 
    $data['demand_results'] = $this->demands_model->get_demand_details($id); 
    $data['candidates'] = $this->demands_model->get_candidates($id, $data['get_map_demand']); 
    //print_r($data['candidates']) ; 
    $this->load->view("list_map_demand_to_candidate",$data); 
} 


function list_search_mapdemand($id) 
{ 
    $data['titlte'] = "mapdemand"; 
    $data['demand_id'] = $id; 
    $data['get_map_demand'] = $this->demands_model->get_exist_demand_map_from_prospect($id); 
    //print_r($data['get_map_demand']); 
    //print_r($data['get_map_candidate']); 
    $data['get_mapped_demand'] = $this->demands_model->get_exist_prospective_candidate($id); 
    $data['demand_results'] = $this->demands_model->get_demand_details($id); 
    $data['candidates'] = $this->demands_model->get_candidates($id, $data['get_map_demand']); 
    //print_r($data['candidates']) ; 
    $this->load->view("list_map_demand_to_candidate",$data); 
} 

一個控制器將在搜索列表中使用,另一個是正常名單。我必須根據控制器明智地重定向頁面,但必須控制一個視圖頁面。對於ADD,EDIT,VIEW。添加後必須去提到的控制器。

回答

1

可以做一些這樣的事<form action="<?php echo $action;?>"和東西像下面的控制器一樣。

public function edit() { 
// plus form validation or what ever you want 
$this->getForm(); 
} 

public function add() { 
// plus form validation or what ever you want 
$this->getForm(); 
} 

public function getForm() { 

// Make sure your uri segment correct uri segment 4 for me is id. 

// http://localhost/codeigniter/project/admin/website/edit/54 

// http://localhost/codeigniter/project/admin/website/add 

    if ($this->uri->segment(4) === FALSE) { 
    $data['action'] = site_url('admin/website/add'); 
    } else { 
    $data['action'] = site_url('admin/website/edit/' . $this->uri->segment(4)); 
    } 

    return $this->load->view(folder/file, $data); 
} 
0

將此添加到您的功能。像你list_mapdemand功能

$data['link']="YOUR_SUBMIT_LINK_FROM_list_mapdemand_FUNTION"; 

,並在您的list_search_mapdemand功能添加

$data['link']="YOUR_SUBMIT_LINK_FROM_list_search_mapdemand_FUNTION"; 

現在使用$鏈接您的視圖從標籤

<from ... action="<?php echo $link; ?>....> 
相關問題