Magento – Create Custom Drop down on registration page

custommagento-1.9register

I would like to create custom drop down on all registration pages.
That drop down will have customer from another group.
enter image description here

This is my Pro.php file which is stored in app/code/local/KitchOff/CustomerRegistration/Model/entity and show different dropdown options

<?php 
    class KitchOff_CustomerRegistration_Model_Entity_Pro extends Mage_Eav_Model_Entity_Attribute_Source_Abstract { 
        public function getAllOptions() { 
            if ($this->_options === null) { 
                $this->_options = array(); 
                $this->_options[] = array( 'value' => '', 'label' => 'Choose Option..' ); 
                $this->_options[] = array( 'value' => 1, 'label' => 'Pro1' ); 
                $this->_options[] = array( 'value' => 2, 'label' => 'Pro2' ); 
                $this->_options[] = array( 'value' => 3, 'label' => 'Pro3' ); } 
                return $this->_options; 
            } 
        }
    } 

This is my config.xml which is stored in app/code/local/KitchOff/CustomerRegistration/etc

<?xml version="1.0"?>
<config>
    <modules>
        <KitchOff_CustomerRegistration>
            <version>1.0.0</version>
        </KitchOff_CustomerRegistration>
    </modules>
    <global>
        <helpers>
            <kitchoff_customerregistration>
                <class>KitchOff_CustomerRegistration_Helper</class>
            </kitchoff_customerregistration>
        </helpers>
        <resources>
            <kitchoff_customerregistration_setup>
                <setup>
                    <module>KitchOff_CustomerRegistration</module>
                    <class>Mage_Customer_Model_Resource_Setup</class>
                </setup>
            </kitchoff_customerregistration_setup>
        </resources>
    </global>
</config>

This is my install-1.0.0.php which is stored in app/code/local/CustomerRegistration/sql/kitchoff_customerregistration_setup/
startSetup();

$setup = Mage::getModel('customer/entity_setup', 'core_setup'); 

$setup->addAttribute('customer', 'pro', array( 
    'type' => 'int', 
    'input' => 'select', 
    'label' => 'Select PRO', 
    'global' => 1, 
    'visible' => 1, 
    'required' => 0, 
    'user_defined' => 1, 
    'default' => '0', 
    'visible_on_front' => 1, 
    'source'=> 'customerregistration/entity_pro'
)); 

if (version_compare(Mage::getVersion(), '1.6.0', '<=')) { 
    $customer = Mage::getModel('customer/customer'); 
    $attrSetId = $customer->getResource()->getEntityType()->getDefaultAttributeSetId(); 
    $setup->addAttributeToSet('customer', $attrSetId, 'Customer', 'pro'); 
} 

if (version_compare(Mage::getVersion(), '1.4.2', '>=')) { 
    Mage::getSingleton('eav/config') ->getAttribute('customer', 'pro') ->setData('used_in_forms', array('adminhtml_customer','customer_account_create','customer_account_edit','checkout_register')) ->save(); 
} 

$installer->endSetup(); 

This is my CustomerRegistration.xml which is stored on app/etc/modules

<?xml version="1.0"?>
<config>
    <modules>
        <KitchOff_CustomerRegistration>
            <active>true</active>
            <codePool>local</codePool>
            <depends><Mage_Customer/></depends>
        </KitchOff_CustomerRegistration>
    </modules>
</config> 

Best Answer

Ok, I just did it, here is how. Go to http://www.silksoftware.com/magento-module-creator/ and using its Module Creator to create a new module called "YourCustomerAttribute".

  1. Set "Add Customer Attribute" to YES
  2. Make proper inputs and selections as you needed.
  3. Make sure to select the forms you needed the new attributes to be used.
  4. Generate the module.
  5. Upload the module to your Magento folder.
  6. Modify located at app/design/frontend/base/default/template/persistent/customer/form/register.phtml and add:

     <div class="input-box">
     <label for="YourAttributeName"><?php echo $this->__('YourAttributeName') ?><span class="required">*</span></label><br />
     <input type="text" name="YourAttributeName" id="YourAttributeID" value="<?php echo $this->htmlEscape($this->getFormData()->getYourAttributeName()) ?>" title="<?php echo $this->__('YourAttributeName') ?>" class="required-entry input-text" />
    </div>
    
  7. If you want customer to be able to modify the attribute in customer panel, then modify app/design/frontend/base/default/template/customer/form/edit.phtm and add:

    <li>
        <label for="YourAttributeName" class="required"><em>*</em><?php echo $this->__('YourAttributeName') ?></label>
        <div class="input-box">
            <input type="text" name="YourAttributeName" id="YourAttributeID" value="<?php echo $this->escapeHtml($this->getCustomer()->getYourAttributeName()) ?>" title="<?php echo $this->__('YourAttributeName') ?>" class="input-text required-entry" />
        </div>
    </li>
    
  8. Refresh all caches.
    You can also Get complete tutorial here.