Hello.

There is a form.

The controller is the simplest:

public function actionIndex(){ $model = Country::findOne(['id'=>1]); if( \Yii::$app->getRequest()->isPost ){ if( $model->load( \Yii::$app->request->post() ) && $model->validate() ){ if ($model->save()) { return $this->render('index',['model' => $model]); } else{ return 1212; } } } return $this->render('index',['model' => $model]); } 

But the model has a function:

 public function TestRules (){ if (Yii::$app->user->can('manager')) { $display = '{update}'; $displayForm = []; return [$display,$displayForm]; } return 122; } 

How can I display a string and an array on the page separately?

After all, with the model comes an array of this function.

For example, I want to display a line on the {update} page,

and through n the distance is the data array $ displayForm.

How can this be implemented?

If you return only the line return, you can use on the view

  $model->TestRules() 

I hope, the problem and the question correctly and clearly explained.

    1 answer 1

     $data = $model->TestRules(); echo $data[0]; //вывод $display echo $data[1]; //вывод $displayForm