-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
route_to() function not work if greater than 3 parameters. #992
Comments
The replacement is occurring because of the same pattern: Test: $routes->get('test/(:any)/(:segment)', 'TestController::index/$1/$2', ['as' => 'testRouter']); |
Maybe preg_replace helps. |
This solves: CodeIgniter4/system/Router/RouteCollection.php:1132 if (preg_match("|{$pattern}|", $params[$index]))
{
$pos = strpos($from, $pattern);
if ($pos !== false)
{
$from = substr_replace($from, $params[$index], $pos, strlen($pattern));
}
} |
Parameters ordering continues working in Controllers: $routes->get('test/(:segment)/(:segment)/(:segment)', 'TestController::test/$2/$1/$3', ['as' => 'testRouter']); http://localhost:8080/test/1/2/3 public function test($param1, $param2, $param3)
{
var_dump($param1);
var_dump($param2);
var_dump($param3);
} |
@natanfelles Thanks for digging into this one! Fix being committed currently. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
In file router.php
$routes->get('test/(:segment)/(:segment)', 'TestController::�index/$1/$2', ['as' => 'testRouter']);
In controller:
echo route_to('testRouter', 1, 2);
or use redirect()->route('testRouter', [1, 2]);
Expected result:
/test/1/2
Actual result:
/test/1/1
Thanks
The text was updated successfully, but these errors were encountered: