"not required" Field in model not saved to database?

I have model that some its field is set “not required”, let’s say user model have 3 field (login,pass, and birth date).

Login and pass are required field for user model.

And i put all 3 field in form, if i fill all the field only (login) and (pass) filed that saved to database.

While (birth date) always NULL or in MySQL its always set "01-01-1970" regardless what i fill in that field.

Just wondering why yii not save data to database that not set as "required" in model rule?

And there is any solution? except set a default value in database and set (birth date) rule to "require" so if the field is empty, the database/yii will fill it with default value.

Thank You.

Even a required field should normally be saved to the database.

Can you post your controller action and the Model class?

Declare a ‘safe’ rule (or it won’t be massively assigned). BTW any rule will do, e.g ‘length’.

See section "Safe Attributes in 1.1"

http://www.yiiframework.com/doc/guide/form.model

/Tommy

‘Safe Attributes’ and ‘massively assigned’ i think i miss those 2 or 4 keyword.

Yes, it’s work now.

Thanks for the reply.