<li class="state">
<label for="State" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="State" name="State" title="<?php echo $this->__('State') ?>" class="validate-select" style="display:none;">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
</select>
<input type="text" id="State" name="State" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
</div>
</li>
答案 0 :(得分:2)
您可以使用获取状态列表:
代码
<li class="state">
<label for="State" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="State" name="State" title="<?php echo $this->__('State') ?>" class="validate-select" style="display:none;">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
<?php
$regionCollection = Mage::getModel('directory/region')->getResourceCollection()
//->addCountryFilter()
->load();
foreach($regionCollection as $region){
echo "<option value=$region[name]>".$region['name'] . "</option>";
}
?>
</select>
<input type="text" id="State" name="State" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
</div>
</li>
注意:此代码注释: // - &gt; addCountryFilter()可以取消注释,如果您想按特定国家/地区进行过滤,例如“美国”或“CA”或“FR”等
答案 1 :(得分:1)
使用目录API代替资源收集:
Mage::getModel('directory/region_api')->items('US')