PHP Error[8] Undefine index: status

I have 2 tables - one called "stage1" and another called "students"

Both, I used Gii to generate the model/controller/view for both tables.

Inside stage1’s view page (index.php), I added a form which will pass two variables to students’s model page (student.php)

The two variables are $_POST[‘status’] and $_POST[‘acadyear’]

Inside students’s model page (Student.php), I set a criteria to use the two variables passed by stage1’s view page (index.php).

Inside students’s view page (adminstage.php), I use zii.widgets.grid.CGridView to use the model page (student.php), that used the two variables as a criteria.

The result was display correctly but when I try to sort by the header (meaning I clicked on one of the column header in the CGridView), it give me the following error:

<h1> PHP Error[8] </h>

<p> Undefine index: status (C:\…\protected\controllers\studentController.php:… </p>

<pre> #0 C:\…protected\controllers\studentcontroller.php:… CWebApplication->handleError()

#1

</pre>

Anyone can enlighten me on how to resolve this problem? Thanks in advance.

I fixed this problem by removing a record that was null and shouldn’t have been.

For any field which can be null, you could use code like this:


'value' => '(($model->field) ? $model->field : "")',

If it isn’t set (is null) then nothing is printed.