cancel
Showing results for 
Search instead for 
Did you mean: 

How to extend customer registration with attributes specially radio button

How to extend customer registration with attributes specially radio button

I want to extend the customer Registration form of the frontend with some custom customer attributes. I tried a TextBox and a RadioButton. The TextBox works perfektly. But the RadioButton value won't stored.

What is wrong?

I added a sql scipt

..
$installer->addAttribute('customer', 'test2', array(
    'type'              => 'int',
    'input'             => 'select',
    'source'            => 'eav/entity_attribute_source_boolean',
    'label'             => 'Test2',
    'global'            => 1,
    'visible'           => 1,
    'required'          => 0,
    'default'           => 0,
    'sort_order'        => 130
));

$attribute = $eavConfig->getAttribute('customer', 'test2');
$attribute->setData('used_in_forms', $forms);
//$attribute->setData('is_user_defined', 0);
$attribute->save();


$installer->addAttribute('customer', 'test', array(
    'type'              => 'text',
    'input'             => 'text',
    'source'            => 'eav/entity_attribute_source_boolean',
    'label'             => 'Test',
    'global'            => 1,
    'visible'           => 1,
    'required'          => 0,
    'default'           => 0,
));

$attribute = $eavConfig->getAttribute('customer', 'test');
$attribute->setData('used_in_forms', $forms);
//$attribute->setData('is_user_defined', 0);
$attribute->save();
...

I extend my config

 

<global>
    ...
    <fieldsets>
        <customer_account>
            <test>
                <create>1</create>
                <update>1</update>
            </test>
            <test2>
                <create>1</create>
                <update>1</update>
            </test2>
         </customer_account>
    </fieldsets>
    ...
</global>

I extend a copy of register.phtml

 

<!--Text Test-->
        <li>
            <label for="test" class="required"><em>*</em><?php echo $this->__('Test') ?></label>
            <div class="input-box">
                <input type="text" autocapitalize="off" autocorrect="off" spellcheck="false" name="test" id="test_1" value="<?php echo $this->escapeHtml($this->getFormData()->getTest()) ?>" title="<?php echo $this->quoteEscape($this->__('Test')) ?>" class="input-text required-entry" />
            </div>
        </li>

        <!--Radio Button Test-->
        <li class="field">
            <label class="required"><em>*</em><?php echo $this->__('Do you want to ...?');?></label>

            <div class="field">

                <!--Yes-->
                <input type="radio" id="yes_test2" name="test2" value="0" <?php if($this->getFormData()->getTest2()): ?> checked="checked"<?php endif; ?> class="validate-one-required-by-name" />
                <label for="yes_test2">
                    <span title="<?php echo $this->__('Yes');?>"><?php echo $this->__('Yes');?></span>
                </label>

                <!--No-->
                <input type="radio" id="no_test2" name="test2" value="1" checked="checked" class="validate-one-required-by-name" />
                <label for="no_test2">
                    <span title="<?php echo $this->__('No');?>"><?php echo $this->__('No');?></span>
                </label>

            </div>
        </li>