0

I need to add a checkbox to the admin customer edit form. I can successfully add the checkbox using this code:

<?php

$name = 'test_foo';
$forms = array('adminhtml_customer');
$baseDir = dirname(__FILE__);

require_once($baseDir . '/app/Mage.php');

umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

$installer = new Mage_Customer_Model_Resource_Setup('core_setup');
$installer->startSetup();

$installer->addAttribute(
    'customer',
    $name,
    array(
        'input' => 'checkbox',
        'type' => 'int',
        'label' => 'Test Foo',
        'visible' => true,
        'global' => 1,
        'default' => '0')
);

Mage::getSingleton('eav/config')
    ->getAttribute('customer', $name)
    ->setData('used_in_forms', $forms)
    ->setData('sort_order', 99)
    ->setData('is_user_defined', 1)
    ->setData('is_required', 0)
    ->setData('is_system', 0)
    ->save();

$installer->endSetup();

But then when I edit a customer and click save it says "please wait" forever. If I remove this new attribute then saving a customer works instantly. So how can I add this checkbox without messing up the customer edit functionality?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.