Yii CreatUrl not returning the full URL

You just can’t seem to get the URL that you expect and all the forums say just call createUrl and it’ll do everything for you!

Na-ugh! Wrong!  It’s returning just the action – or the controller/action but not the module.

First

First check your UrlManager rules because these are central to how createUrl builds the URL. If you’ve left out a “/” or your URLs are ending in “/”s then createUrl will get confused.

Then …

Check that you are calling Yii::app()->controller->createUrl (which can often be $this->createUrl() ) rather than Yii::app()->createUrl() as the latter will not return relative URLs!

 

That’s it – you should be working now

Let’s Start a Project!

Contact Me