Skip to content
Advertisement

Setting Parameters in CI4s redirecting function

is there any possible way to send parameters within the redirection function from Codeigniter 4? Important, it is a named route:

JavaScript

And i want to do a redirect like this:

this works fine:

JavaScript

this would be nice, if it works:

JavaScript

or

JavaScript

Why? I have HMVC and I would like to name every module with the same routes but different functions ofc. And this would help me having same site urls. (edit, add, a.s.o.)

Advertisement

Answer

The short answer is no its not possible. Take a look at system/Common.php and you’ll see there is only 1 parameter to the redirect() function.

The longer answer however is take a look at what the redirect function does.

JavaScript

Based on the current (4.1.4) redirect function you’ll see it calls route(). It turns out that route() allows a second parameter which are the parameters.

So the solution would probably be to do your own redirect() function (see https://codeigniter.com/user_guide/extending/common.html?highlight=common) and allow a second parameter.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement