我已经创建了一个带有一些字段的自定义模块。我已经使用Varien_Data_Form创建表单与字段。我已经添加了单选按钮,我只想在这些单选按钮之间添加一个<div>
。我不知道该怎么做。
表单的单选按钮代码:
$productField=$fieldset->addField('radio2', 'radios', array(
'name' => 'house_building',
'value' => '1',
'class' => 'house_building',
'values' => array(
array('value'=>'1','label'=>'House','id'=>'house'),
array('value'=>'2','label'=>'Building','id'=>'house'),
),
));
我已经打印了这个表单在视图页使用:
<?php echo $this->getChildHtml("suggestions_edit_form") ?>
我有两个单选按钮,格式如下:
<div class="value">
<input name="house_building" class="house_building" value="1" id="radio21" checked="checked" type="radio"><label class="inline" for="radio21">House</label>
<input name="house_building" class="house_building" value="2" id="radio22" type="radio"><label class="inline" for="radio22">Building</label>
</div>
现在我想改变这是在以下格式与额外的div
标签:
<div class="value">
<div class="field-container col-xs-12 col-sm-12 col-md-12 col-lg-12">
<input type="radio" checked="checked" id="radio21" value="1" class="house_building validation-passed" name="house_building">
<label for="radio21" class="inline">House</label>
</div>
<div class="field-container col-xs-12 col-sm-12 col-md-12 col-lg-12">
<input type="radio" id="radio22" value="2" class="house_building validation-passed" name="house_building">
<label for="radio22" class="inline">Building</label>
</div>
</div>
我不知道该怎么做?
谁能帮我解决这个问题?
我已经为那个特定的单选按钮单独添加了一个帮助器:
My helper file:
class NextBits_Marketplace_Block_Form_Helper_Type extends Varien_Data_Form_Element_Text
{
/**
* Validation classes for weight field which corresponds to DECIMAL(12,4) SQL type
*
* @param array $attributes
*/
public function __construct(array $attributes = array())
{
parent::__construct($attributes);
}
public function getElementHtml()
{
$html = '<div class="field-container col-xs-12 col-sm-12 col-md-12 col-lg-12">';
$html .="<input type=radio checked=checked id=radio21 value=1 class=house_building validation-passed name=house_building>
<label for=radio21 class=inline>House</label></div>";
$html .='<div class="field-container col-xs-12 col-sm-12 col-md-12 col-lg-12">';
$html .="<input type=radio id=radio22 value=2 class=house_building validation-passed name=house_building>
<label for=radio22 class=inline>Building</label>";
$html .= '</div>';
$html .= $this->getAfterElementHtml();
return $html;
}
}
我刚刚在Varien_Data_Form addfield中调用了这个助手:
$fieldset->addType('type', 'NextBits_Marketplace_Block_Form_Helper_Type');
$fieldset->addField('type', 'type', array(
'name' => 'house_building',
'value' => '1',
'class' => 'house_building',
'container_class' => 'col-xs-12 col-sm-12 col-md-12 col-lg-12 customer-profile-radio'
));
现在我得到了添加了div标签的输出。