Yii Framework Forum: problem with redirect and parameters - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

problem with redirect and parameters Rate Topic: -----

#1 User is offline   StErMi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 259
  • Joined: 30-March 09

Posted 13 January 2010 - 04:41 PM

i'm trying to do this:

$this->redirect( array('site/index','user'=>$user, 'toDo' => new Todo));

the error is: urlencode() expects parameter 1 to be string, object given

the documentation says: http://www.yiiframew...redirect-detail

where am I wrong?
0

#2 User is offline   gallego123 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 535
  • Joined: 11-August 09
  • Location:Argentina

Posted 13 January 2010 - 04:55 PM

View PostStErMi, on 13 January 2010 - 04:41 PM, said:

i'm trying to do this:

$this->redirect( array('site/index','user'=>$user, 'toDo' => new Todo));

the error is: urlencode() expects parameter 1 to be string, object given

the documentation says: http://www.yiiframew...redirect-detail

where am I wrong?


"new Todo" Does this create an array?

Quote

public void redirect(mixed $url, boolean $terminate=true, integer $statusCode=302)

the URL to be redirected to. If the parameter is an array, the first element must be a route to a controller action and the rest are GET parameters in name-value pairs.



the rest are GET parameters in name-value pairs.
KISS - Keep It Simple Stupid
ASAP-As Soon As Possible
http://www.yiiframew...oc/cookbook/71/
0

#3 User is offline   jerry2801 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 504
  • Joined: 18-November 09

Posted 13 January 2010 - 07:59 PM

class Todo
{
public function __toString() { return '1'; }
}
0

#4 User is offline   Sander 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 169
  • Joined: 03-November 09
  • Location:Amsterdam, Netherlands

Posted 14 January 2010 - 04:22 AM

Yeah the key/value pairs in the parameter array should be strings-only, as they are passed via the querystring of the url. Obviously, it's impossible to pass an unserialized object that way (and passing a serialized one is messy). Best to create the new Todo on the redirected page, and omit passing it in the querystring.
0

#5 User is offline   StErMi 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 259
  • Joined: 30-March 09

Posted 14 January 2010 - 08:43 AM

ops my fault :P
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users