Magento Extension – Fix Admin Attribute Not Saving

extensionsmagento-1.9

I've built an extension, which is all working correctly on my local / development Magento website, unfortunately after packaging it up and installing on another Magento store, the new attributes I've added to the Admin User don't seem to be saving to the Database.

Here is the code, not sure if I've missed something out of the extension package or what but everything seems to be there so it's confusing me now!

From my extensions config.XML

<blocks>
    <adminhtml>
        <rewrite>
            <permissions_user_edit_tab_main>Liquid11_Veridial_Block_Adminhtml_Permissions_User_Edit_Tab_Main</permissions_user_edit_tab_main>
            <permissions_user_grid>Liquid11_Veridial_Block_Adminhtml_Permissions_User_Grid</permissions_user_grid>
        </rewrite>
    </adminhtml>
</blocks>

Here is what is in Liquid11_Veridial_Block_Adminhtml_Permissions_User_Edit_Tab_Main

/**
 * Add additional Mobile number to Admin user record for Veridial's use
 */
$fieldset->addField('veridial_mobile', 'text', array(
    'name'  => 'veridial_mobile',
    'label' => Mage::helper('adminhtml')->__('Mobile Number'),
    'id'    => 'veridial_mobile',
    'title' => Mage::helper('adminhtml')->__('Mobile Number'),
    'class' => 'required-entry input-text',
    'required' => true,
));

/**
 * Add additional Landline number to Admin user record for Veridial's use
 */
$fieldset->addField('veridial_landline', 'text', array(
    'name'  => 'veridial_landline',
    'label' => Mage::helper('adminhtml')->__('Telephone Number'),
    'id'    => 'veridial_landline',
    'title' => Mage::helper('adminhtml')->__('Telephone Number'),
    'class' => 'input-text',
));

And finally my MySQL code to add the columns to the database (2 separate files)

$installer = $this;
$installer->startSetup();

$installer->getConnection()->addColumn($installer->getTable('admin/user'), 'veridial_landline', array(
    'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
    'length' => 256,
    'nullable' => true,
    'default' => null,
    'comment' => 'Telephone Number'
));

$installer->endSetup();

and

$installer = $this;
$installer->startSetup();

$installer->getConnection()->addColumn($installer->getTable('admin/user'), 'veridial_mobile', array(
    'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
    'length' => 256,
    'nullable' => true,
    'default' => null,
    'comment' => 'Mobile Number'
));

$installer->endSetup();

So, the issue is – The above all seems to work. Admin/user/edit tab is correct (It's got my additional fields) and the Database columns have been added. If I add the data into the Database table itself then it's picked up in the Admin area. For some reason saving the admin/user/edit form just doesn't save the data in veridial_mobile and veridial_landline.

Cache etc has all been refreshed after installing the extension.

Best Answer

The solution was to ensure the cache was cleared completely by removing the contents within /var/cache - Rather than relying on the Magento cache controls in the admin area.

Perhaps due to the table schemas being cached as per Marius' comment.

Related Topic