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 に答える