简体   繁体   English

codeigniter 中的 controller 到 controller

[英]controller to controller in codeigniter

i have a php page where i have a link which calls a controller function page_view .我有一个 php 页面,我有一个链接调用 controller function page_view within that controller function there are some codes which retrieve data using models and store in variable data then a view is loaded as $this->load->view('common/view_plan',$data);在 controller function 中有一些代码使用模型检索数据并存储在可变数据中,然后将视图加载为 $this->load->view('common/view_plan',$data);

in the view_plan page there is a form.view_plan页面中有一个表格。 when this form is submitted the data in the form is to be saved and then should get redirected to the same view_plan .提交此表单时,表单中的数据将被保存,然后应重定向到相同的view_plan so i wrote a controller function to save the data.所以我写了一个 controller function 来保存数据。 but how can i redirect to the same page.但我怎样才能重定向到同一页面。 can i call the controller function page_view from another controller我可以从另一个 controller 调用 controller function page_view

If you are submitting and showing the form in the same method of the same controller you could do something like this:如果您以相同 controller 的相同方法提交和显示表单,则可以执行以下操作:

public function view_page() {
   if (!empty($_POST)) {
      // your form submission logic here
   }

   // your regular steps with fetching data from model and showing in the view
   $this->load->view('common/view_plan',$data);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM