如何调用两个不同的控制器一种观点认为,将用户重定向根据笨

问题描述:

控制器我想根据控制器重定向表单提交明智如何调用两个不同的控制器一种观点认为,将用户重定向根据笨

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。添加后必须去提到的控制器。

可以做一些这样的事<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); 
} 

将此添加到您的功能。像你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; ?>....>