I'm a beginner at cakephp.
Is it possible to specify which page to display in the page country of cakephp?
I am thinking about the following:
1. Display a list form with pageation.
2. Display the detailed form of the selected record from the list form.
3. Update the record in the detail form and return to the list form.
4. Display the list form on the page where it was in the state of 2.
Would it be possible for the controller to specify a page for pageation?
Thank you for your cooperation.
php cakephp
Is it possible to specify which page to display in the page country of cakephp?
The answer to this question is yes.
In this example,
3. Update the record in the detail form and return to the list form.
In the action method at the time of the , specify the redirect destination to be performed at the end of the process.
return$this->redirect(['action'=>'index', '?'=>['page'=>2]);
You can specify pages as shown in .
However, you need to know which page to go back to here.If the index action has features such as search, you would like to take over the search option.
To do so, use the
1. Display a list form with pageation.
The index action in allows you to save query parameters in a session and retrieve them when redirecting 3.
public function index()//List
{
// ...
$this->request->session()
->write('ControllerName.index.query', $this->request->getQuery());// session key name changed as appropriate
}
public function edit() // detail form
{
// ...
if(/*...*/){
// Redirect when the process completes successfully
return $this->redirect([
'action' = > 'index',
'?' =>$this->request->session()
->consume('ControllerName.index.query'), read and delete in //consume
]);
}
// ...
}
In this case, if you open an index of different display conditions on multiple tabs, you will return to the last index display conditions that you opened, due to the nature of keeping the state in the session.
© 2024 OneMinuteCode. All rights reserved.