I was able to upgrade to 3.0.8.
The code itself can reload the page but cannot do it if I have other code that needs the stateparameters returned… Here’s the code that I am currently working on:
Since we have a full page redirection we can only return the redirect as a return parameter. So please check your code if it will work if you change it to:
Can you please give more information? It should be something with the response I guess. Can you press right click “Inspect” and then go to “Console” tab to see if you have any JavaScript errors? If not then check the response of your request. Press the “Network” tab and check the last request. My blind guess is that those 3 lines:
By the way, the 3 lines actually are working fine when tested on their own.
Here’s the observation that I gathered:
The reload works on the first attempt but will fail if I edit the record again and save. Through observation, I found out that once the link being passed our reload to is the same link in the address bar it would trigger just the loading but will not proceed. Refer to the image:
My current workaround is to randomly pick a link the reroutes to the same page:
$crud->callbackAfterUpdate(function ($stateParameters){
$submitStatus = $this->_getDataSubmitStatus();
$this->_step3($submitStatus);
$this->_updateRelatedTable();
/* LINK RANDOMIZER BEGIN: LARA'S WORK-AROUND IS TO RANDOMLY PICK THE URL TO LOAD FOR STEP 2 */
$links = [
base_url().'profile#step2',
PATM_BASEURL.'profile#step-2',
base_url().'../profile#step2',
];
// Retrieve previously selected links from session or initialize an empty array
$selectedLinks = $_SESSION['selected_links'] ?? [];
// If all links have been selected, reset the selection
if (count($selectedLinks) === count($links)) {
$selectedLinks = [];
}
// Filter out previously selected links from the available options
$availableLinks = array_diff($links, $selectedLinks);
// Randomly select a link from the available options
$randomLink = $availableLinks[array_rand($availableLinks)];
// Store the selected link in the session
$selectedLinks[] = $randomLink;
$_SESSION['selected_links'] = $selectedLinks;
/* LINK RANDOMIZER END */
$redirectResponse = new \GroceryCrud\Core\Redirect\RedirectResponse();
return $redirectResponse->setUrl($randomLink);
});