如何将单个属性添加到单选按钮?据我所知,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">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>
答案 0 :(得分:0)
试试这个:
$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);
答案 1 :(得分:-1)
echo $this->Form->input('title', array('type' => 'radio', 'class' => 'custom-class', 'atributeName' => 'attributeValue'));