Persistent parameter of component is not carried over on presenter redirect

29 days ago

josef.sabl
Member | 136
+
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;
    }
}

29 days ago

David Matějka
Moderator | 5128
+
+3
-

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

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

29 days ago

josef.sabl
Member | 136
+
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