Jonas
Jonas

Reputation: 301

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?

Upvotes: 4

Views: 2467

Answers (1)

Jonas
Jonas

Reputation: 301

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...

Upvotes: 14

Related Questions