3

I've created 2 new customer attributes. These attributes show in the admin under "Customers > Attributes > Manage Customer Address Attributes".

I've overwritten the registration form (register.phtml) to display form fields matching these attributes. When I debug through the registration process, I see that Mage_Customer_Model_Form::getAttributes does not include my new attributes.

Because of this (I think), my new attributes are not being saved in the database. What step am I missing to make the registration form save my new attributes?

4

Add the attribute to the form-filter

To save new attributes in an EAV table through a form, you need to set the used_on_forms setting, like this in a setup file

$oAttribute = Mage::getSingleton('eav/config')->getAttribute(
     'customer', 'agb'
);
$oAttribute->setData('used_in_forms', array('adminhtml_customer', 'customer_account_create'));

There are a lot more forms, like customer_account_edit.

Be careful, this example is from a customer attribute, not customer address!

A few form codes:

SELECT DISTINCT form_code FROM `customer_form_attribute` WHERE 1
  • adminhtml_checkout
  • adminhtml_customer
  • adminhtml_customer_address
  • checkout_register
  • customer_account_create
  • customer_account_edit
  • customer_address_edit
  • customer_register_address

I'm not sure whether I got all, maybe there are some, which are not used but mentioned in the code.

  • Is there a list of forms? I have it registered in several, but apparently not the right ones. – Ryre Feb 28 '13 at 17:44
  • 1
    I edited the answer. I don't think there is a list. – Fabian Blechschmidt Feb 28 '13 at 17:50
  • AHA! I registered the attribute to use the customer_register form, but not the customer_register_address form! – Ryre Feb 28 '13 at 18:07
  • I cross my fingers, that this worked. I hoped, this might be the problem. – Fabian Blechschmidt Feb 28 '13 at 18:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.