Persistent parameter of component is not carried over on presenter redirect

3 years ago

josef.sabl
Backer | 153
+
0
-

I have component named MyComp that has persistent parameter $foo and it lives in my HomepagePresenter, particularly it is used in Default action. I also have another action called RedirectFoo($foo) that is supposed to set the $foo parameter of MyComp to specific value. It however doesn't seem to work and the persistent parameter not carried over on redirect.

I have it like this:

class MyComp extends \Nette\Application\UI\Control
{
	/** @persistent */
	public $foo;
}

class HomepagePresenter extends BasePresenter
{
	public function actionRedirectFoo($foo)
	{
		$this['myComp']->foo = $foo;
		$this->redirect('default');
	}


	public function createComponentMyComp()
	{
		return new MyComp;
	}
}

3 years ago

David Matějka
Moderator | 6161
+
+4
-

you can mark a component as a persistent, iirc it should look like this:

/**
* @persistent(myComp)
*/
class HomepagePresenter

3 years ago

josef.sabl
Backer | 153
+
0
-

Didn't know about this feature, it works, thank you!

David Matějka wrote:

you can mark a component as a persistent, iirc it should look like this:

/**
* @persistent(myComp)
*/
class HomepagePresenter