redirect in YII2

Hello friends

Why it does not work

public function actionStepJobs()

{





    return $this->redirect('jobs', 302);





}

Not Found (#404)

Page not found.

Check views files name "jobs" exist?

Thanks for help

I have only one file name "jobs"!

use render as redirect searchfor action in controller nd u have no actionJobs in ur controller so it gives u #404

return $this->render(‘jobs’, 302);

And do you also have a controller action to render the "jobs" view?

no i have actionStepJobs and i wont to redirect to my custom page named Jobs

Maybe Im missing something??

Should declare in controller for a new page??

if im use render its ok but im wont to use redirect

then u have to create action for that.

and if u use authorization there u also have to add the action name.

public function [color="#FF0000"]actionView/color

{


    return $this->render('view', [


        'model' => $this->findModel($id),


    ]);


}

public function actionCreate()

{


    $model = new Country();





    if ($model->load(Yii::$app->request->post()) && $model->save()) {


        [color="#FF0000"]return $this->redirect(['view', 'id' => $model->countryId]);[/color]


    } else {


        return $this->render('create', [


            'model' => $model,


        ]);


    }


}

Does it work like this?


public function actionStepJobs()

{


return $this->redirect(['jobs'], 302);


}

Thanks

It’s my Mistake had to refer to the action and it will turn to the file name

$step = ‘Jobs’

public function actionStepJobs()

{

$step = $this->getCurrentStep();

    return $this->redirect(["step-$step", ['id' => $id]]);

}

:rolleyes: