Change Gender DropDown to Radio Button in Magento



If you want to change gender dropdown to radio button in magento this tutorial will help you. By default magento having a gender dropdown on registration page. On registration form magento uses widgets, you can see following lines on template register.phtml.

<?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
<?php if ($_gender->isEnabled()): ?>


<li><?php echo $_gender->setGender($this->getFormData()->getGender())->toHtml() ?></li>


<?php endif ?>

So you can found gender widget template file on template\customer\widget folder. Now to change gender dropdown to radio button replace below code into the file.


<div class="input-box">
    <?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();
        $value = $this->getGender();
        $_last = count($options);
        $i = 0;
    ?>
    <?php foreach ($options as $option):?>
        <?php if($option['value'] != ''): ?>
            <input class="radio<?php if ($this->isRequired() && $i == $_last - 1):?> validate-one-required<?php endif; ?>" type="radio" title="<?php echo $option['label'] ?>" value="<?php echo $option['value'] ?>" name="<?php echo $this->getFieldName('gender')?>" <?php if ($option['value'] == $value) echo ' checked="checked"' ?> />
			<?php echo $option['label'] ?>
			
        <?php endif; ?>
        <?php $i++; ?>
    <?php endforeach;?>
</div>

Hope this tutorial will help you to change gender dropdown to radio button on registration in magento.