CActiveDataProvider is being used to create a paginated list of results from a search form I made.
First page works properly but if I click on page 2 for example, it clears the CActiveDataProvider instead of switching results. Can anyone tell me what is happening.
function actionSearch() {
if (!empty($_POST['id'])) {
$searchResults = $this->search($_POST);
}
// render to view with $searchResults
}
function search($postData) {
// Search using the $postData in $criteria
// Creates a 5 page pagination CActiveDataProvider using the $criteria
return $dataProvider;
}
Sorry for the minimal code I am trying to simply what to look at this is the basic algoritm for the search method and how it builds the CActiveDataProvider.
Since I built a basic pagination in a sandbox app for testing I didn’t pass variables in a POST form, so that worked as expected, but now that I have used it in a search where I pass variables in POST I am not sure how to get past this issue. Thanks in advance for the help.
then as mentioned by softark using $_GET if $_POST isn’t populated in my action.
Problem: In my example version it does it without posting those attributes to the url, in my website it is posting all of them in the url but it works. I would prefer the cleaner look.