How To Get Additional Information In Model And Post It?

I am working on an attendance system. I have the following model:


This is the model class for table "attendance_student".

 *

 * The followings are the available columns in table 'attendance_student':

 * @property string $id

 * @property string $student_id

 * @property string $class_grade_id

 * @property string $course_id

 * @property string $date

 * @property string $status_id

 *

 * The followings are the available model relations:

 * @property Course $course

 * @property Student $student

 * @property Status $status

 * @property ClassGrade $classGrade

and my form looks like the 4368

from.png

The table and courses comes from the ajax call to the following action when the dropdown of class changes.


public function actionDynamicStudents()

        {            

            $class_grade_id = $_POST['AttendanceStudent']['class_grade_id'];

            $data =  Course::model()->findAllByAttributes(array('class_grade_id'=>$class_grade_id));

            

            $class = ClassGrade::model()->findByPk($class_grade_id);

            

            $dataProvider = new CArrayDataProvider($class->students);

            

           $data=CHtml::listData($data,'id','name');

           

           // turn output buffering on

            ob_start();

            foreach($data as $value=>$name)

            {     

                echo CHtml::tag('option',

                   array('value'=>$value),CHtml::encode($name),true);

             }

            $html = ob_get_clean();

            //CVarDumper::Dump($html, 100, true);

            

            $table = $this->renderPartial('pages/_view_grid', array('dataProvider'=> $dataProvider),true);

            

            echo CJSON::encode(array(

                'options'=>$html,

                'table'=>$table

            ));

        }

Now the problem is, how can I get the ids of all students and the corresponding ids of the value shown in the attendance column dropdown, then pass those values by POST to create action so that they can be stored?

The current vardump is


array

(

    'AttendanceStudent' => array

    (

        'class_grade_id' => '1'

        'course_id' => '2'

        'date' => '2013-06-04'

        'status_id' => '9'

    )

    'yt0' => ''

)

Hi, if your form is a CGridView you could add a CCheckBoxColumn column for the students, and then it’s very easy to treat a list.

You can look for detailed solution in the forum i think.