Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2: Controller action not receiving parameter from route

I have a weird issue that I think is configuration related. I have pretty urls on, and I have a route defined as:

'/customers/update/<id:\d+>' => '/customers/default/update' 

And for good measure my action:

public function actionUpdate($id) {}

My controller is part of a module and maps correctly but my action doesnt seem to be receiving the parameter. If i leave out the parameter in the route and the action, the action gets called correctly and if I give the parameter a default value everything works as intended. To summarise, I get an error saying parameter 1 is missing.

Any ideas?

like image 542
Jonas Avatar asked Oct 15 '25 16:10

Jonas


1 Answers

Ugh, solved it. I was extending the wrong controller class... I was using

yii/base/Controller

instead of

yii/web/Controller

Could have been looking for this for a while...

like image 167
Jonas Avatar answered Oct 17 '25 07:10

Jonas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!