I have a custom module that adds a field to an element in

<?php

class NS_MN_Block_Cms_Page_Edit_Tab_Main extends Mage_Adminhtml_Block_Cms_Page_Edit_Tab_Main
{

public function _prepareForm()
{
parent::_prepareForm();

 $fieldset = $this->getForm()->getElements()->searchById('base_fieldset');

$fieldset->addField('bar', 'text',
    array(
        'label' => Mage::helper('cms')->__('BaR'),
        'class' => 'input-text',
        'name'  => 'bar',
        'required' => false
    )
);
return $this;
}
}

I have added the bar field into the cms_page table and the field is rendered, but when I save the cms page, the field is not saved to the database.

Could anyone tell me what I am overlooking here?

有帮助吗?

解决方案

You need to remember to flush your cache. This one has caught me out a few times before.

Go into System > Cache Management and click both flush buttons.

Log out of the admin and log back in. Everything should function as expected.

其他提示

Have you added the field to the database? Having the field in the form is one step, but in order to persist the data it must be able to live in a column in the DB. Once the field is in the DB, you might have to change the controller to recognize the new field, but it might already work for all fields. If it is already doing a setData($data) where $data is all received form data, you should be fine.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top