Magento 1.9 – How to Add Customer Attribute Field to Registration Form

customer-attributefrontendmagento-1.9registertheme

I'm creating an extension, which defines some customer attributes. I added these attributes to the adminhtml, so the admin can set these attributes, but I cannot find a way to add this field to the customer's registration (to the frontend) from code.

Since this is an extension I need to add this from code and not with cloning/overriding a template file to be compatible with other extensions.

Can You please let me know, what is the best way to do this?

Thanks in advance for Your answers!

Best Answer

You can add your attributes through a layout update. There is a call for a block inside the customer registration template:

<?php echo $this->getChildHtml('form.additional.info'); ?>

You can use this to add your block:

<customer_account_create>
    <reference name="form.additional.info">
        <block type="yourBlockClass" name="yourAttributes" template="yourTemplate"/>
    </reference>
</customer_account_create>

Your content will be visible under the password field and above the register button.

If the position in the template doesn't fit your needs, then there are only ugly options like:

  • Add your content via Javascript on document ready
  • Add your content via template override
  • Add your content via string replace on magento block output event
Related Topic