Add database field to model and make it editable using Varien_Data_Form
-
22-10-2019 - |
Pergunta
I have a model in an extension. I want to add a new database attribute and make this value editable through Magento admin using Varien_Data_Form. I have added the field to the database through installer script, the field is displayed on the admin, but I don't know how to save it.
The form data is posted and saved to a $data variable, the model is loaded and has a setData($data) called, and after that the model is saved, but to no avail. Dumping $data just before the setData() call shows the variable is fine.
Saving occurs inside a try block, no errors are thrown/catched.
...
$model = Mage::getModel('cmspro/category');
$model->setData($data)->setId($this->getRequest()->getParam('id'));
...
try {
...
$model->save();
...
} catch (Exception $e) {
...
}
Solução
After changing the structure of a table clear the cache.
Delete the contents of var/cache
.
Even if the cache is disabled the table schema is still cached by Zend Framework.