Views params not shared between views Yii2

Hi all,

I need help about a question which I have proposed some day ago in Stack Overflow forum, at the moment I’ve no receive answers hope someone here will help me.

I’ve a controller with 3 actions for a simple procedure in 3 steps, my idea is to have breadcrumbs like

Home page / Step1 / Step2 / Step3

each view have


$this->params['breadcrumbs'][] = 'StepX';

and the layout/main.php


Breadcrumbs::widget([

            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],

        ])

However in every view the breadcrumbs are respectively for Step1, Step2 and Step3

Home page / Step1

Home page / Step2

Home page / Step3

Can anyone help me?

Thanks

If you want more breadcrumbs, you have to add more:




$this->params['breadcrumbs'][] = 'Step 1';

$this->params['breadcrumbs'][] = 'Step 2';

$this->params['breadcrumbs'][] = 'Step 3';



Ok, but the view’s params isn’t shared among the view template?

From the documentation

They are only shared between views in one action/request. Once you start a new action, the params are "reset".

Now everything is clear, then, for share between distinct views, the only way is using session, right?

Try to think in terms of requests or actions, not views. And yes, sessions allow you to share data between them.