I want to generate URL's that can handle multiple parameters as follows.
www.mysite.com/index.php/controller/param1/param2/param3/param4/mySlug
But still be able to be flexible and pass over less information
www.mysite.com/index.php/controller/param1/parama/my_slug_2
We could assume there's always a slug at the end if that makes this easier. Is there anything in the Yii2 urlManager I can implement this.
This works a bit nicer, as it allows for any number of optional params, great if for example you're creating a category tree that may be x levels deep (you also don't need slug if not needed):
In the config:
You can then get an array of all possible params in the controller:
Just configure your rule with default values of your params like this:
All the parameters, that have default value are not required and may be skipped. Here are the examples of behaviour:
http://yii2.local/test/slug:
http://yii2.local/test/2/4/slug
Horrible that this is a 2 year question, and the answer is so simple.
The idea is that for some reason when the ActiveForm is not well configure for the GET requests, specifically on the action, it will cause this weird effect.
This can get solved by simply adding a well configured action to the $form = ActiveForm.
On Yii2:
This will get rid of this horrible effect. For more info on this read the Yii forum
I hope this helps any other, that runs on the problem.