Saving New Fields Problem

Hi all,

I have created a model for schedule last week, and just now I added schoolyear to my table fields. I edited my _form so that it will ask for a year, but when I click on save, nothing happened to the newly added field.

I checked the codes in actionCreate, comparing the var_dump of $model->attributes with $_POST[‘Schedule’] and these are the results:

var_dump($model->attributes);




array

  'user_id' => string '21' (length=2)

  'time' => string '' (length=0)

  'days' => string '' (length=0)

  'id' => null

  'schoolyear' => null



VS var_dump($_POST[‘Schedule’]);




array

  'user_id' => string '21' (length=2)

  'time' => string '' (length=0)

  'days' => string '' (length=0)

  'schoolyear' => string '2006' (length=4)



Should there be another file that I need to edit so as to make this work? I though this should be automatic, because I thought in the line $model->attributes = $_POST[‘Schedule’], all the values in the $_POST will be saved to the model->attributes.

You need to read this section of The Definitive Guide to Yii.

/Tommy

Hi Tommy,

Thanks for the tip! I’ll keep that in mind :)