How to call action() function in view pge


How to call action() function in view page. I have created two controller. such as:



In my staffController, i create one action as actionStaffview(), and that view page is. staffview.php. In (staffview.php) that view page call one action of ExamController.

This is (staffview.php) view page coding:

$exam=new ExamController($id);


i.e: i create instance($exam) for ExamController and that action as $exam->actionExamType()(This action written inside of ExamController ).

Here that function($exam->actionExamType()) is calling, but nothing to be display. so, please tell solution for that problem.

This is similar case:

Welcome to the forums!

Hello Mr.pestaa,

Thanks for your reply. i saw that your solution. but in renderPartial(…array(‘data’=>)) we can not pass any data because here we can not assign values for that arguments(array(‘data’=>…)).i thing all arguments have null value, null value only pass that renderPartial() ($this->renderPartial(’…/event/viewEvents’, array(‘data’=>…));) . if null value pass that function means then how can we get exact output.


echo $this->renderPartial(’…/event/viewEvents’, array(‘data’=>…));


Yes, they are null unless you specify them. :) If you know you’re going to embed another action’s views, pass all the data to the main view, then pass it on to partial views.

Thanks for your reply. can you send coding? please.

Sure. As I’ve understood, you want to embed ExamController::actionExamType() into StaffController::actionStafview().

Assuming you’re storing all your data in your database, and representing table rows as ActiveRecord models, the embedding is just a little work.

Copy your exam/examtype action’s content into staff/staffview. For example:

public function actionStaffView()


   ... your original code ...

   $examtypes = ExamTypesModel::model()->findAll(); // or something similar according to your application structure

   $this->render('staffview', array('examtypes'=>$examtypes));


This way you can reach exam types from your views.



<?php echo $this->renderPartial('../exam/examtypes', array('examtypes'=>$examtypes)); ?>

And you passed on your variables.

Good luck!