开发者

Passing form data through MVC - Joomla

开发者 https://www.devze.com 2023-02-04 18:02 出处:网络
I\'m creating a search form that shows a singl开发者_如何学Ce user depending on the exact match of the first and last names and a member ID. I have the component shell set up with the form data going

I'm creating a search form that shows a singl开发者_如何学Ce user depending on the exact match of the first and last names and a member ID. I have the component shell set up with the form data going to a custom controller in 'com_medsearch/controllers/search.php'. I've read the tutorials in the Joomla docs, but I'm not sure how to pass the data to the model (com_medsearch/models/search.php) and the query results back to the same view. Answers?


You can do this 2 ways:

  1. You detect that you had a search post in your controller then you call your model and in the model you can use JRequest::getVar / getInt / etc to read your variables.
  2. You detect your search post and read your variables from the post all in your contoller function and pass it to your model.

Here is an example for point 2:

$settings = JRequest::get( 'POST' );
$model = & $this->getModel('settings'); 
$model->saveSettings($settings);

Then in your model you can access your post variables like:

$settings->input_name
0

精彩评论

暂无评论...
验证码 换一张
取 消