今天,我開始在magento網站的註冊表單中工作。正如你所知道的,它有gender drop down
。我需要將其更改爲checkbox
。將性別下拉列表更改爲magento中的單選按鈕
到目前爲止,我去register.phtml
文件,並試圖添加<input type="radio" ...../>
選擇文件,但這並沒有奏效。
有沒有人知道如何解決這個問題! 請給我一些建議,以便這樣....
今天,我開始在magento網站的註冊表單中工作。正如你所知道的,它有gender drop down
。我需要將其更改爲checkbox
。將性別下拉列表更改爲magento中的單選按鈕
到目前爲止,我去register.phtml
文件,並試圖添加<input type="radio" ...../>
選擇文件,但這並沒有奏效。
有沒有人知道如何解決這個問題! 請給我一些建議,以便這樣....
Magento在註冊表格上使用小部件。事實上,在模板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 ?>
這個特殊的小部件可以在template/customer/widget
目錄中找到。因此,爲了改變選擇爲單選按鈕,它(模板)複製到你的主題和修改,例如:
<div class="input-box">
<label><?php echo $this->__('Gender'); ?></label>
<?php $options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();?>
<?php $value = $this->getGender();?>
<?php foreach ($options as $option):?>
<input type="radio" name="<?php echo $this->getFieldName('gender')?>" value="<?php echo $option['value'] ?>"<?php if ($option['value'] == $value) echo ' selected="selected"' ?> /><?php echo $option['label'] ?>
<br />
<?php endforeach;?>
</div>
希望沒有作出任何錯字。
不要忘記驗證!
<div class="input-box">
<?php
$options = Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getAllOptions();
$value = $this->getGender();
$_last = count($options);
$_index = 0;
?>
<?php foreach ($options as $option):?>
<?php if($option['value'] != ''): ?>
<input id="<?php echo $this->getFieldId('gender')?>-<?php echo $option['value'] ?>"
class="radio<?php if ($this->isRequired() && $_index == $_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"' ?>>
<label for="<?php echo $this->getFieldId('gender')?>-<?php echo $option['value'] ?>">
<?php echo $option['label'] ?>
</label>
<?php endif; ?>
<?php $_index++; ?>
<?php endforeach;?>
</div>
它不工作... – Carolina
能否請您幫忙解決這個問題http://stackoverflow.com/questions/36595547/convert-dropdown-to-selection-boxes-with-color – Manik