I have created a small search and filter form with a POST action in controller/index, which POSTs to itself the conditions and fields to paginate ($this->paginate($
You can also use the Post/Redirect/Get design pattern pattern to solve this, allowing users to bookmark URLs of searches (without them expiring as a session would) and keeping URLs looking friendly. For example:
function index($searchTerms = null) {
// post/redirect/get
if (isset($this->data['SearchForm'])) {
$this->redirect(array($this->data['SearchForm']['search_terms']));
}
// your normal code here.
}
The search form data POSTs to /controller/action
but the user is redirected and instead GETs /controller/action/search+terms
where the terms are passed into the action as a parameter (ie. $searchTerms
).
If you simply change the form submission method to GET you will instead see something like: /controller/action?data[SearchForm][search_terms]=search+terms