rude
(Cf 15094)
July 23, 2012, 7:43pm
1
I’m using createAbsoluteUrl to generate an activation URL for new users, but am getting the following error:
Recoverable error
Object of class SiteController could not be converted to string
The code usage is as follows:
if ($model->save(false))
{
$url = $model->$this->createAbsoluteUrl('activation/validatekey', array('key'=>$model->activationKey));
//TODO: send activation e-mail
}
This is happening within the controller the error is referencing, leaving me a bit baffled as to where it is being ‘converted to string’. Any tips are appreciated! Thank you.
// wrong
$model->$this->createAbsoluteUrl() <img src='http://www.yiiframework.com/forum/public/style_emoticons/default/huh.gif' class='bbc_emoticon' alt='???' />
// correct
Yii::app()->createAbsoluteUrl();
// OR
$this->createAbsoluteUrl(); // if in view file or controller.
Lilt
(Colin)
July 23, 2012, 7:55pm
3
You have an extra "$model->" in there. Try:
$this->createAbsoluteUrl(…);
instead of
$model->$this->createAbsoluteUrl(…);
rude
(Cf 15094)
July 23, 2012, 8:04pm
4
Thank you both for the quick replies. I was working off of an example that had the extra $model in there curiously.
I wonder if his/her code worked
Again, much appreciated.