Update Model

Hi folks, I want to ask about model. I’ve already built a model using gii generator, then I realize I should add or even erase some attribute in the table. How can I update the generated code model. Just by make new public attribute? or overwrite the previous model?

If overwrite the previous model, should I add or update again some code that I’ve already modified in the model (like adding beforeSave() and change label in attributeLabel again)? :huh: .

Depends on how much you have change the gii generated code:

Save a copy of the current model/controller/views and regenerate the model/controller/views with gii.

Compare the code with a diff tool and add beforeSave … again.

OR

Remove/add the changed dbfield in the model and the view files:

  • Check the model methods: rules(),attributeLabels() and search()

    Remove/add the changed dbfield.

  • Check the view files:

* columns of gridview in admin.php


* fields in _form.php for create/update.