Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Add Custom field for customer registration and also display in admin side in Magento
 
pradeep_kumar67
Sr. Member
 
Avatar
Total Posts:  160
Joined:  2010-06-24
Bangalore
 

Hi,

To create new attribute or field to customer follow the steps in this given below link

http://www.magentocommerce.com/wiki/5_-_modules_and_development/customers_and_accounts/registration_fields

To display in admin side Follow this steps

Override this app\code\core\Mage\Adminhtml\Block\Customer\Edit\Tab\Account.php
to ur local folder

override only initForm() funtion and
after this line

$this->_setFieldset($attributes$fieldset);

Add this code

$fieldset->addField('occupation''text',
            array(
                
'name'  => 'occupation',
                
'label'         => 'Occupation',
                
'class' => 'text',
                
'required' => false,
            )
        );
 
Magento Community Magento Community
Magento Community
Magento Community
 
pradeep_kumar67
Sr. Member
 
Avatar
Total Posts:  160
Joined:  2010-06-24
Bangalore
 

This is a alternative solution to display customer custom attribute display in admin side

when you creating new attribute you have run a code

$this->addAttribute('customer_address''address_activated', array(
    
'type' => 'int',
    
'input' => 'select',
    
'label' => 'Is activated',
    
'global' => 1,
    
'visible' => 1,
    
'required' => 0,
    
'user_defined' => 1,
    
'default' => 0,
    
'visible_on_front' => 0,
));
add this code after above one

Mage::getSingleton('eav/config')
    ->
getAttribute('customer_address''address_activated')
    ->
setData('used_in_forms', array('adminhtml_customer_address'))
    ->
save();
which make this attribute will display in admin side
 
Magento Community Magento Community
Magento Community
Magento Community
 
Jamie Jackson
Jr. Member
 
Avatar
Total Posts:  23
Joined:  2010-03-05
Sheffield, UK
 

Nice little tutorial and a alternative to the customer attributes module.

 
Magento Community Magento Community
Magento Community
Magento Community
 
redstarx
Jr. Member
 
Total Posts:  18
Joined:  2012-02-17
 
pradeep_kumar67 - 05 July 2012 10:26 PM

Hi,

To create new attribute or field to customer follow the steps in this given below link

http://www.magentocommerce.com/wiki/5_-_modules_and_development/customers_and_accounts/registration_fields

To display in admin side Follow this steps

Override this app\code\core\Mage\Adminhtml\Block\Customer\Edit\Tab\Account.php
to ur local folder

override only initForm() funtion and
after this line

$this->_setFieldset($attributes$fieldset);


Add this code

$fieldset->addField('occupation''text',
            array(
                
'name'  => 'occupation',
                
'label'         => 'Occupation',
                
'class' => 'text',
                
'required' => false,
            )
        );

The tutorial has been quite useful but I’m a bit stuck at the last part to have the newly added custom field show on the admin side.

I tried to do as you have suggested but I’m a bit confused as of how to properly override the account.php file mainly because my account.php file has this

$this->_setFieldset($attributes$fieldset, array($disableAutoGroupChangeAttributeName));

instead of this as you mentioned

$this->_setFieldset($attributes$fieldset));

should I create a new account.php file to place under my local module with the following info? should it look like this?

<?php
class MyCompany_Adminhtml_Block_Customer_Edit_Tab_Account extends Mage_Adminhtml_Block_Widget_Form
{
    
public function initForm()
    
{

$this
->_setFieldset($attributes$fieldset);

$fieldset->addField('occupation''text',
            array(
                
'name'  => 'occupation',
                
'label'         => 'Occupation',
                
'class' => 'text',
                
'required' => false,
            )
        ); 
    
}
}

or should I just place your code on the copy of the account.php file and keep everything else in the file the same?

I’m sorry, I’m kinda new at editing magento and I’ve done everything I can to my knowledge and following instructions.

 
Magento Community Magento Community
Magento Community
Magento Community
 
pradeep_kumar67
Sr. Member
 
Avatar
Total Posts:  160
Joined:  2010-06-24
Bangalore
 

@redstarx

please copy full initForm() function to you override Account.php

and after

$this->_setFieldset($attributes$fieldset, array($disableAutoGroupChangeAttributeName));
add this code

$fieldset->addField('occupation''text',
            array(
                
'name'  => 'occupation',
                
'label'         => 'Occupation',
                
'class' => 'text',
                
'required' => false,
            )
        );

Or else Run this code

Mage::getSingleton('eav/config')
    ->
getAttribute('customer_address''address_activated')
    ->
setData('used_in_forms', array('adminhtml_customer_address'))
    ->
save();
 
Magento Community Magento Community
Magento Community
Magento Community
 
IonDigital
Jr. Member
 
Avatar
Total Posts:  2
Joined:  2011-03-16
Chesterfield, United Kingdom
 

Used this a few times many thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
jur erick
Member
 
Total Posts:  38
Joined:  2011-01-11
 

i tried your instructions., the created custom field was present in form, but its not saving.

my magento version is 1.7

 
Magento Community Magento Community
Magento Community
Magento Community
 
Amasty
Mentor
 
Avatar
Total Posts:  3988
Joined:  2009-11-10
 

Hello,

you can also check out Customer Attributes extension. It helpd add an unlimited number of fields to registration page.Then you can manage the collected data in the admin panel.

 
Magento Community Magento Community
Magento Community
Magento Community
 
aheadWorks
Guru
 
Avatar
Total Posts:  424
Joined:  2008-10-30
 

Hi!

There is a ready-made module - the Customer Attributes Magento extension that gives you a possibility to create additional customer attributes and display them on the registration form or in the customer account area to allow logged in visitors to manage their data. Your customers are asked to leave some additional info and you get knowledge about them immediately.

Find the complete extension description, screenshots, and demo version on the extension page.

 
Magento Community Magento Community
Magento Community
Magento Community
 
FMEExtensions
Mentor
 
Avatar
Total Posts:  1298
Joined:  2009-08-07
 

The following Magento extension allows you to add various input/output fields on customer registration form. These custom fields can also be added from admin panel, Visit Customer registration fields plugin on Magento Connect.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top