How To Visualize One Model In Another Model View?

Could you please help?

There is a project, a user and an issue. Project may have many users, project may have many issues, issue may have one user.

I want to to create an issue for a project.

  1. I would like during issue creation to assign automatically loged_in_user and selected_project to corresponding issue table fields(model attributes)

  2. I want to make dropdown list to select user for issue during issue creation, i mean loged_in user selects project, than creates issue, but he can assign different user for the issue.


//Protected/views/project/view.php

// I am creating menu item to create issue from project view

… $this->menu=array(

 array('label'=>'Create Issue', 'url'=>array('issue/create', 'pid'=>$model->id)),

….


//Protected/views/issue/create.php

//I am rendering _form.php with model variable, model here means issue

… <?php $this->renderPartial('_form', array('model'=>$model)); ?> ..


//Protected/views/issue/_form.php

// I am visualizing issue table columns (issue model attributes)

// how to make dropDownlist of users, which belong to project

//where and how to define function getUserOptions()

..<?php $form=$this->beginWidget('CActiveForm', array('id'=>'issue-form',

	'enableAjaxValidation'=>false,

)); ?>

...<?php echo $form->dropDownList($model,'owner_id',

	$this->getProject()->getUserOptions()); ?>...

//CASE 1. TASK = assign automatically loged_in_user and project to corresponding issue which is being created. I do not know how to get loged_in_user “id” in issue _form.php? How to get project “id” for which I create issue in issue _form.php?

//CASE 2. TASK = to make dropdown list to select user for issue during issue creation.

//The example which I have found does not look correct. Why getUserOptions is in Project model, i believe t should be in IssueControler? Example implements this getUserOptions()function in Project model:


//Protected/models/Project.php

…

	public function relations()

	{

	return array(

		'issue' => array(self::HAS_MANY, 'Issue', 'project_id'),

            'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),

		);

	}


	public function getUserOptions()

	{

//example which I have found does not look correct, :

  $usersArray = array(); 

  return $usersArray;


//i believe here should be used current project id

//how to read current project id, I mean project for which I am creating issue

	$modelProject=Project::model()->findbyPk($id)

	$usersArray =  $modelProject->users;

	 return $usersArray;

	}


Yii::app()->user->id

will return current users id

would be


$modelProject->id

but i would really need the controller action code and the controller load function for the project id tell 100%

also

appears to retuning an empty array which is why it’s not showing anything.