通过代码在客户帐户中启用字段

I'm developing a module where it will change the value of the field Display Date of Birth and View CPF/CNPJ in Settings>customers>settings>name and address options.

When this value is set as required, it shows fields in the customer master in "customer / account / create /", for this I use the following code in an installation script, so that when the module is activated it already enable these fields that do not come by default.

Code:

$inchooSwitch = new Mage_Core_Model_Config();

$inchooSwitch->saveConfig('customer/address/dob_show', "req", 'default', '');
$inchooSwitch->saveConfig('customer/address/taxvat_show', "req", 'default', '');

Code changes successfully, but when I access the page customer/account/create/ fields do not appear.

Any idea why this happens?

update

I used the hint of Himansu, but happens the same as before does not show the fields on the page:

fields

as you can see not appear on the Birth Date field

update x2

yes, it changes value in core_config_data table, but does not show the field on the page, do not understand why it does not show the fields on the page

table

I used the suggestion of Himansu and changed this:

$inchooSwitch = new Mage_Core_Model_Config();

$inchooSwitch->saveConfig('customer/address/dob_show', "req", 'default', '');
$inchooSwitch->saveConfig('customer/address/taxvat_show', "req", 'default', '');
$inchooSwitch->saveConfig('customer/address/gender_show', "req", 'default', '');

for this:

Mage::getModel('core/config')->saveConfig('customer/address/dob_show', 'req');
Mage::getModel('core/config')->saveConfig('customer/address/taxvat_show', 'req');
Mage::getModel('core/config')->saveConfig('customer/address/gender_show', 'req');

then I saw the system.xml they used a backend_model adminhtml/system_config_backend_customer_show_customer, which possessed the _afterSave function that set the attribute as visible and necessary, so I used:

$dobAtribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', 'dob');
$dobAtribute->setData('is_required', 1);
$dobAtribute->setData('is_visible', 1);
$dobAtribute->save();

$taxvatAtribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', 'taxvat');
$taxvatAtribute->setData('is_required', 1);
$taxvatAtribute->setData('is_visible', 1);
$taxvatAtribute->save();

$genderAtribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', 'gender');
$genderAtribute->setData('is_required', 1);
$genderAtribute->setData('is_visible', 1);
$genderAtribute->save();

all code:

<?php

Mage::getModel('core/config')->saveConfig('customer/address/dob_show', 'req');
Mage::getModel('core/config')->saveConfig('customer/address/taxvat_show', 'req');
Mage::getModel('core/config')->saveConfig('customer/address/gender_show', 'req');

$dobAtribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', 'dob');
$dobAtribute->setData('is_required', 1);
$dobAtribute->setData('is_visible', 1);
$dobAtribute->save();

$taxvatAtribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', 'taxvat');
$taxvatAtribute->setData('is_required', 1);
$taxvatAtribute->setData('is_visible', 1);
$taxvatAtribute->save();

$genderAtribute = Mage::getModel('eav/entity_attribute')->loadByCode('customer', 'gender');
$genderAtribute->setData('is_required', 1);
$genderAtribute->setData('is_visible', 1);
$genderAtribute->save();

Thanks for all

Use below code anywhere for chnage config data.

Mage::getModel('core/config')->saveConfig('YOUR_PATH_HERE', 'YOUR_VALUE_HERE');

So change your code as below.

Mage::getModel('core/config')->saveConfig('customer/address/dob_show', 'req' );
Mage::getModel('core/config')->saveConfig('customer/address/taxvat_show', 'req' );