0

Follow up to Adding attributes to customer entity

My goal is to make new attribute appear on the registration form. I've added $oAttribute->setData('used_in_forms', array('customer_account_create', 'adminhtml_customer')); call which should add the new field. Point is to add new field without modifying register.phtml template directly. I will also need to hook into registration save method to handle ability to select custom answer e.g. 'Other'

Thanks in advance

Community
  • 1
  • 1
Zifius
  • 1,650
  • 1
  • 16
  • 27
  • problem is that the new attribute doesn't appear on the registration form also it works just fine in backend – Zifius May 17 '11 at 15:24

1 Answers1

0

the thing is that in the admin all defined customer fields are rendered automatically, but in the frontend they are added in the template (customer/form/register.phtml).
As you don't want to edit the phtml file, you could listen for example to controller_action_layout_load_before, check if the fullActionName is customer_account_create and then include a layout handle of your module which refers to a template file containing the field you want to add. See for more detailed code my last question.

Then you'll need another observer listening to Mage_Customer_AccountController's createPostAction method to process the field's value.
Hope That Helps

Community
  • 1
  • 1
OSdave
  • 8,538
  • 7
  • 45
  • 60
  • I see, so there seems no use for `customer_account_create` in this case at all? However considering http://stackoverflow.com/questions/4549112/can-no-longer-add-registration-fields-in-magento-1-4-2-0/4617655#4617655 it probably helps loading the attribute value – Zifius May 18 '11 at 07:08