cancel
Showing results for 
Search instead for 
Did you mean: 

setData or addData not saving all values

SOLVED

setData or addData not saving all values

Hi,

 

I created my custom module and want to save data from a form in the controller with the setData / addData method. But magento doesn't saving all columns.

 

Here the entity layout:

CREATE TABLE IF NOT EXISTS mp_bank_account (
	id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	bank_name VARCHAR(125) NOT NULL DEFAULT '',
	account_holder VARCHAR(125) NOT NULL DEFAULT '',
	iban VARCHAR(100) NOT NULL DEFAULT '',
	bic VARCHAR(100) NOT NULL DEFAULT '',
	accept_direct_debit TINYINT(1) NULL DEFAULT '0',
	PRIMARY KEY (id)
)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8

 

Here is the method of the controller:

 

    public function editPostAction()
	{
		$data = $this->getRequest()->getParams();

		die(print_r($data));
		
		try 
		{		
			$helper = Mage::helper('mymodule/bankaccount');		
			
			$bankAccount = $helper->getBankAccount();
			
			$bankAccount->setData($data);
			$bankAccount->save();	

			$message = "Bank Account saved.";
			Mage::getSingleton('core/session')->addSuccess($message);	
		} 
		catch (Mage_Core_Exception $e)
		{
			Mage::getSingleton('core/session')->addError($e->getMessage());		
		} 
		catch (Exception $e) 
		{				
			Mage::getSingleton('core/session')->addError($e->getMessage());				
		} 

		$this->_redirect('mymodule/bankaccount/edit');
    }

And here is the result from the form post:

 

Array ( [id] => 1 [form_key] => ImvZTObfXmbWaeX1 [bank_name] => Bank [account_holder] => Accountholder [iban] => IBAN [bic] => BIC [accept_direct_debit] => 0 ) 1

The problem is that the account holder isn't saved.

 

Any ideas?

 

Regards

Marco

3 REPLIES

Re: setData or addData not saving all values

Hello,

 

You can post your helper : Mage::helper('mymodule/bankaccount') ?

I think you should create a Model to work with database. You can read a series here: http://www.boolfly.com/magento-brand-extension-part-1/

Problem solved? Click Accept as Solution!

Re: setData or addData not saving all values

Could it be that you added "account_holder" field a little later than the rest of fields? Magento tends to cache this stuff and even with cache being disabled in admin, you still need to flush it! So my suggestion is to click "Flush Cache" button in admin. Check if that helps. This is as much as I can tell from what you have described.

Re: setData or addData not saving all values

Thanks for your answers. Flushing the whole cache was the solution. I disabled the cache so I thought I haven not to flush cache again...