Answer the question
In order to leave comments, you need to log in
Correct organization of the call structure from the controller?
Kind. Again, I'm tormented by children's questions. Guys, tell me how to properly organize such a construction of calls?
In a nutshell. The Action is given a parameter, and then it is sorted out according to the case.
But apparently, this is possible somehow simply and possibly not correctly.
How would "correctly" knowledgeable people do it?
public function actionIndex( $task = null ){
switch ( $task ) {
case 'settings': return $this->render('index', []); break;
case 'showallpages': return $this->render('pagelist', []); break;
case 'editpage':
$model = new Page( Yii::$app->request->get('pageId') );
return $this->render( 'editPage', [ 'model' => $model ] );
break;
case 'savepage':
return 'SAVED !!!!!';
break;
default: return $this->render( 'index', [] ); break;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question