I got the same issue no drop down on Owner_Id and requester_id.
Project.php
<?php
/**
-
The followings are the available columns in table ‘tbl_project’:
-
@property integer $id
-
@property string $name
-
@property string $description
-
@property string $create_time
-
@property integer $create_user_id
-
@property string $update_time
-
@property integer $update_user_id
*/
class Project extends CActiveRecord
{
/**
* Returns the static model of the specified AR class.
* @param string $className active record class name.
* @return Project the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'tbl_project';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('create_user_id, update_user_id', 'numerical', 'integerOnly'=>true),
array('name', 'length', 'max'=>128),
array('description, create_time, update_time', 'safe'),
// The following rule is used by search().
// Please remove those attributes that should not be searched.
array('id, name, description, create_time, create_user_id, update_time, update_user_id', 'safe', 'on'=>'search'),
array('name, description', 'required'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'issues' => array(self::HAS_MANY, 'Issue', 'project_id'),
'users' => array(self::MANY_MANY, 'User', 'tbl_project_user_assignment(project_id, user_id)'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'name' => 'Name',
'description' => 'Description',
'create_time' => 'Create Time',
'create_user_id' => 'Create User',
'update_time' => 'Update Time',
'update_user_id' => 'Update User',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
*/
public function search()
{
// Warning: Please modify the following code to remove attributes that
// should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('name',$this->name,true);
$criteria->compare('description',$this->description,true);
$criteria->compare('create_time',$this->create_time,true);
$criteria->compare('create_user_id',$this->create_user_id);
$criteria->compare('update_time',$this->update_time,true);
$criteria->compare('update_user_id',$this->update_user_id);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* @return array of valid users for this project, indexed by user IDs
*/
public function getUserOptions()
{
$usersArray = CHtml::listData($this->users, 'id', 'username');
return $usersArray;
}
}
My Issue/view.php
<?php
/* @var $this IssueController */
/* @var $model Issue */
$this->breadcrumbs=array(
'Issues'=>array('index'),
$model->name,
);
$this->menu=array(
array('label'=>'List Issue', 'url'=>array('index')),
array('label'=>'Create Issue', 'url'=>array('create')),
array('label'=>'Update Issue', 'url'=>array('update', 'id'=>$model->id)),
array('label'=>'Delete Issue', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
array('label'=>'Manage Issue', 'url'=>array('admin')),
);
?>
<h1>View Issue #<?php echo $model->id; ?></h1>
<?php $this->widget(‘zii.widgets.CDetailView’, array(
'data'=>$model,
'attributes'=>array(
'id',
'name',
'description',
'type_id',
'status_id'
array(
'name'=>'owner_id',
'value'=>CHtml::encode($model->owner->username),
),
array(
'name'=>'requester_id',
'value'=>CHtml::encode($model->requester->username),
)
),
)); ?>
My Issue/_form.php
<?php
/* @var $this IssueController */
/* @var $model Issue */
/* @var $form CActiveForm */
?>
<div class="form">
<?php $form=$this->beginWidget(‘CActiveForm’, array(
'id'=>'issue-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="note">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<div class="row">
<?php echo $form->labelEx($model,'name'); ?>
<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>256)); ?>
<?php echo $form->error($model,'name'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'description'); ?>
<?php echo $form->textField($model,'description',array('size'=>60,'maxlength'=>2000)); ?>
<?php echo $form->error($model,'description'); ?>
</div>
<div class="row">
<?php echo $form->hiddenField($model,'project_id'); ?>
<?php echo $form->hiddenField($model,'project_id'); ?>
<?php echo $form->error($model,'project_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'type_id'); ?>
<?php echo $form->dropDownList($model,'type_id', $model->getTypeOptions()); ?>
<?php echo $form->error($model,'type_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'status_id'); ?>
<?php echo $form->dropDownList($model,'status_id', $model->getStatusOptions()); ?>
<?php echo $form->error($model,'status_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'owner_id'); ?>
<?php echo $form->dropDownList($model,'owner_id', $this->getProject()->getUserOptions()); ?>
<?php echo $form->error($model,'owner_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'requester_id'); ?>
<?php echo $form->dropDownList($model,'requester_id', $this->getProject()->getUserOptions()); ?>
<?php echo $form->error($model,'requester_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'create_time'); ?>
<?php echo $form->textField($model,'create_time'); ?>
<?php echo $form->error($model,'create_time'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'create_user_id'); ?>
<?php echo $form->textField($model,'create_user_id'); ?>
<?php echo $form->error($model,'create_user_id'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'update_time'); ?>
<?php echo $form->textField($model,'update_time'); ?>
<?php echo $form->error($model,'update_time'); ?>
</div>
<div class="row">
<?php echo $form->labelEx($model,'update_user_id'); ?>
<?php echo $form->textField($model,'update_user_id'); ?>
<?php echo $form->error($model,'update_user_id'); ?>
</div>
<div class="row buttons">
<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>
</div>
<?php $this->endWidget(); ?>
</div><!-- form -->
Thank you.