sharmila
sharmila

Reputation: 175

how to connect the data from backend to frontend using links in Yii framework

I need to access the data from a backend file by using a link in frontend.

Find the code below :

     $model = new LoginForm();
    if ($model->load(Yii::$app->request->post()) && $model->login()) {
        return $this->render('hello');
    } else {
        $model->password = '';

        return $this->render('login', [
            'model' => $model,
        ]);
    } 

In the above code instead of hello, I need to pass to farmers page which is in the following location "C:\xampp\htdocs\f_project_yii\backend\views\farmer".

Upvotes: 0

Views: 177

Answers (2)

When you are use a

$this->render('hello');

You must to have a ./protected/views/[Controller name in lowcase]/hello.php file

Upvotes: 0

user10414646
user10414646

Reputation: 23

One of solution to set absolute path to view like this

$model = new LoginForm();
    if ($model->load(Yii::$app->request->post()) && $model->login()) {
        return $this->render('/farmer');
    } else {
        $model->password = '';

        return $this->render('login', [
            'model' => $model,
        ]);
    } 

Upvotes: 1

Related Questions