I added my customer attribute.
But I want to display these fields as checkboxes. I created checkbox in the frontend easily but the backend is not. And then save to the database. Please help me. Thanks.
my script
<?php
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'biz_confirmation', array(
'label' => 'Business Customer Confirmation',
'type' => 'int',
'input' => 'checkbox',
'visible' => true,
'required' => true,
'default' => '0',
));
$setup->addAttribute('customer', 'marketing_consent', array(
'label' => 'Marketing Consent',
'type' => 'int',
'input' => 'checkbox',
'visible' => true,
'required' => false,
'default' => '0',
));
$setup->addAttribute('customer', 'b2b_contact_consent', array(
'label' => 'B2B Contact Consent',
'type' => 'int',
'input' => 'checkbox',
'visible' => true,
'required' => false,
'default' => '0',
));
$setup->addAttribute('customer', 'biz_confirmation_time', array(
'label' => 'Business Customer Confirmation Update Time',
'type' => 'datetime',
'input' => 'datetime',
'visible' => false,
'required' => false,
));
$setup->addAttribute('customer', 'mkt_consent_updated_time', array(
'label' => 'Marketing Consent Update Time',
'type' => 'datetime',
'input' => 'datetime',
'visible' => false,
'required' => false,
));
$setup->addAttribute('customer', 'b2b_consent_updated_time', array(
'label' => 'B2B Contact Consent Update Time',
'type' => 'datetime',
'input' => 'datetime',
'visible' => false,
'required' => false,
));
$attributeCodes = array(
'biz_confirmation',
'marketing_consent',
'b2b_contact_consent',
'biz_confirmation_time',
'mkt_consent_updated_time',
'b2b_consent_updated_time'
);
foreach($attributeCodes as $code) {
$attribute = Mage::getSingleton("eav/config")->getAttribute('customer', $code);
$used_in_forms = array(
'adminhtml_customer',
'checkout_register',
'customer_account_create',
'customer_account_edit');
$attribute->setData("used_in_forms", $used_in_forms)
->setData("is_used_for_customer_segment", true)
->setData("is_system", 0)
->setData("is_user_defined", 1)
->setData("is_visible", 1)
->setData("sort_order", 100);
$attribute->save();
}