I have used this tutorial before for adding registration fields to the Magento registration page.
It has always worked, but since I have upgraded to Magento 1.4.2.0 it no longer does. The attributes I add no longer show up under the customers information tab in the backend like it did before and are not getting saved. The attributes install into the database fine though. I thought maybe the config.xml part had changed but I checked it against the core customer one and the attributes are sill shown the same way:
<flavour><create>1</create><update>1</update></flavour>
Something must have changed since the last 1.4.2 beta because it worked fine then. If someone has any ideas it would be greatly appreciated and I could finally get some sleep! Thanks in advance!
I have been struggling with this one quite some time untill I figured it out. Since 1.4.2, the attributes to show in the admin's customer's form have to be in table customer_form_attribute.
You can add them with an upgrade in your module's setup, with this code:
$eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer', 'your_attributes_code');
$attribute->setData('used_in_forms', array('adminhtml_customer'));
$attribute->save();
Hope that helps.
Very usefull hints above, thank you David!
To make the new attributes saveable in frontend (register and edit)
just expand the second parameter array of $attribute->setData like this:
$eavConfig = Mage::getSingleton('eav/config');
$attribute = $eavConfig->getAttribute('customer', 'flavour');
$attribute->setData('used_in_forms', array('customer_account_edit',
'customer_account_create',
'adminhtml_customer'));
$attribute->save();
After that you will find 3 new entries in the customer_form_attribute table instead of one.
If you want to test this before and after this change, just insert
Mage::log('attrib: '. (string)$attribute->getAttributeCode());
after line 371 in app/code/core/Mage/Customer/Model/Form.php and you will see all the used attributes in the mage system log. (valid for mage 1.4.2.0)
try this one :
http://www.magento.cc/custom-accountregistration-fields.html
FYI everyone, they removed the 'special code' in community edition that shows all the custom attributes. I use enterprise and we were considering community edition due to the savings. This is one of the hurdles we will have to overcome.
Doesn't answer the question, but explains probably why they removed it from the free edition. The code to display them is completely missing from the theme.