I created a custom module to add Land Phone field in registration page
. The form display the field but in database the Land Phone number is not inserted
. But in eav_attribute table
the landphone attribute is added. The only issue is the value of Land Phone is not inserted in customer table. I followed this tutorial: http://www.fontis.com.au/blog/magento/know-more-about-your-customers-adding-custom-signup-attributes
I will give you the detailed code what i did.
My module name is TCreg_Customer
app/etc/modules/TCreg_Customer.xml
<?xml version="1.0"?>
<config>
<modules>
<TCreg_Customer>
<codePool>local</codePool>
<active>true</active>
</TCreg_Customer>
</modules>
</config>
app/code/local/TCreg/Customer/etc/config.xml
I copy app/code/core/Mage/Customer/etc/config.xml
file and make 2 changes
<modules>
<TCreg_Customer>
<version>1.0.0</version>
</TCreg_Customer>
</modules>
and add
<landphone><create>1</create><update>1</update></landphone>
inside <customer_account>
tag
app/code/local/TCreg/Customer/Model/Entity/Setup.php
<?php
class TCreg_Customer_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup
{
public function getDefaultEntities(){
return array(
'landphone'=>array(
'type'=> 'varchar',
'label'=> 'Land Phone',
'visiable' => true,
'sort_order' => 80,
)
);
}
}
?>
The Land Phone field is set in register.phtml
located in app/design/frontend/mytheme/template/persistent/customer/form/register.phtml
<!--landphone field begin-->
<div class="field">
<label for="landphone"><?php echo $this->__('Land Phone') ?></label>
<div class="input-box">
<input type="text" name="landphone" id="landphone" value="<?php echo $this->escapeHtml($this->getFormData()->getLandphone()) ?>" title="<?php echo $this->__('Land Phone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('landphone') ?>" />
</div>
</div>
<!--landphone field end-->
app/design/frontend/mytheme/template/persistent/customer/address/edit.phtml
<!--Landphone field begin-->
<div class="field">
<label for="landphone"><?php echo $this->__('Land Phone') ?></label>
<div class="input-box">
<input type="text" name="landphone" value="<?php echo $this->htmlEscape($this->getAddress()->getLandphone()) ?>" title="<?php echo $this->__('Land Phone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('landphone') ?>" id="landphone" />
</div>
</div>
<!--Landphone field end-->
The new attribute (land phone) needs to be added to the Magento database. So I added these bit of code in register.phtml
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'landphone', array(
'label' => 'Land Phone',
'type' => 'varchar',
'input' => 'text',
'visible' => true,
'position' => 1,
));
I think the only issue is the value of Land phone is not inserted in customer table. But I can't find the solution. So please help me .. How can I solve this?? Any help is really appreciable..
My magento version is 1.9.1.0