CakePHP-如何向单个单选按钮添加属性?
如何向单选按钮添加单个属性?据我所知,CakePHP只允许向组中的所有单选按钮添加相同的(有限的)属性 比如说,有没有关于如何产生这种效果的想法CakePHP-如何向单个单选按钮添加属性?,cakephp,radio-button,Cakephp,Radio Button,如何向单选按钮添加单个属性?据我所知,CakePHP只允许向组中的所有单选按钮添加相同的(有限的)属性 比如说,有没有关于如何产生这种效果的想法 <input type="radio" checked="checked" value="0" name="data[MyModel][field]" id="custom-id-1" class="custom-class-1" data-something="test1"> <label for="custom-id-1">
<input type="radio" checked="checked" value="0" name="data[MyModel][field]" id="custom-id-1" class="custom-class-1" data-something="test1">
<label for="custom-id-1">Test 1</label>
<input type="radio" checked="checked" value="0" name="data[MyModel][field]" id="custom-id-2" class="custom-class-2" data-something="test2">
<label for="custom-id-2">Test 2</label>
测试1
测试2
echo$this->Form->input('title',array('type'=>'radio','class'=>'custom class','atributeName'=>'attributeValue'))代码>试试这个:
$options = array('1' => 'Test 1'); <br> $attributes =
array('value'=>'1','class'=>'custom-class-1','id'=>'custom-id-1','data-something'=>'test1');
echo $this->Form->radio('field_name1', $options, $attributes);
---------------------
$options = array('1' => 'Test 2'); <br> $attributes =
array('value'=>'1','class'=>'custom-class-2','id'=>'custom-id-2','data-something'=>'test2');
echo $this->Form->radio('field_name2', $options, $attributes);
$options=array('1'=>'test1')
$attributes=
数组('value'=>'1','class'=>'custom-class-1','id'=>'custom-id-1','data-something'=>'test1');
echo$this->Form->radio('field_name1',$options,$attributes);
---------------------
$options=数组('1'=>'测试2')
$attributes=
数组('value'=>'1','class'=>'custom-class-2','id'=>'custom-id-2','data-something'=>'test2');
echo$this->Form->radio('field_name2',$options,$attributes);
您是否有一个示例可以生成一组具有模型关联的单选按钮?你能举个例子生成我发布的HTML吗?