Form With No Related Models

hi!!

i have 4 models: student, behavior, location and assignment.

assignment model (id, studentID, behaviorID, LocationID)

i want to create a form for the assignment (create action). in this form i want to make a subform for searching a student by name or any other info.

i want to write something like:

<?php echo $form->label($model,‘Student_Number’); ?>

<?php echo $form->textField($model,‘Student_Number’,array(‘size’=>15,‘maxlength’=>15)); ?>

<?php echo $form->label($model,‘Student_Name’); ?>

<?php echo $form->textField($model,‘Student_Name’,array(‘size’=>15,‘maxlength’=>15)); ?>

if i write ($model, student_Name) in the assignment/_form it gives me an error, student_Name variable not exist. how to use the student model data in the view?

can i do something like this in the Assignment controller/create:

&#036;model=new Assignment;


&#036;student = new Student;

thank you

To search a student i’ll put a CGridView with student’s rows

in the assignment/_form, so operator can search student with

different filtering field, sort order, …

sorry i am new in yii, can you please be more specific.

if i put CGridView,

$this->widget(‘zii.widgets.grid.CGridView’, array(

'id'=&gt;'action-grid',


'dataProvider'=&gt;&#036;model-&gt;search(),


'filter'=&gt;&#036;model,

$model here represent assignment (the current model), how to represent the student model?

In your assignment/_form, you could have after

textField, ecc… a gridview to display grid of students,

so:




$this->widget('zii.widgets.grid.CGridView', array(

'id'=>'action-grid',

'dataProvider'=>Students::model()->search()

'filter'=>$model,

...



Then you have to check selected row of grid, using




'selectionChanged'=>'function(id){ your js code here, you can use $.fn.yiiGridView.getSelection(id) }',



or directly




$.fn.yiiGridView.getSelection(id)