add fields on DB after model created

Hello,

quite often it happens to me that i have to add fields to DB after i created the model and crud in Yii and made many changes to forms, actions and whatever.

I have no problem adding fields to forms, labels to the models eventually add the fields to views and so…

the only thing i can’t understand is why doesn’t


<?

$model->attributes=$_POST['ModelName'];

?>

get the attributes? should i add something more then rules and labels to the model?

Sorry if the question is stupid :) and thanks for helping me out! :)

Because is not marked as "safe"…

It will be if you add some rules for that field…

i actually found it out right now: i added some mandatory fields and they were saved and the one that wasn’t mandatory hasn’t been saved.

thanks a lot!! :)

To get a good understanding of this take a read at the guide - http://www.yiiframework.com/doc/guide/form.model#securing-attribute-assignments