Setting request data - CakePHP 4
P粉212971745
P粉212971745 2024-03-26 14:02:51
0
1
517

We have a CakePHP 3.x application that we have updated to the latest CakePHP 4.x. As part of this work, we also changed from PHP 7 to PHP 8.

While testing the application, we noticed that a feature had stopped working.

The application is a searchable database and integrated with Redis for caching. One of the functions means

For clarity, the reason we set up the request data this way is because the search is done via an ajax call. When the user initially enters the search criteria, the page has not reloaded yet, so the form fields appear to be populated correctly. This issue occurs when the page is reloaded. In this case we want to use them

P粉212971745
P粉212971745

reply all(1)
P粉722521204

The function you are looking for is withData. Remember that the request object is immutable, so you need to assign the result of that function call back to the request object, e.g. with $this->setRequest($this->getRequest()->withData('f1' , 'foo')->withData('f3', 'bar')).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template