6

如何将单个属性添加到单选按钮?据我所知,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>
4

2 回答 2

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);
于 2016-06-25T10:18:23.607 回答
-1

echo $this->Form->input('title', array('type' => 'radio', 'class' => 'custom-class', 'atributeName' => 'attributeValue'));

于 2013-02-20T07:50:52.663 回答