2013-02-19 16 views
6

Jak dodać poszczególne atrybuty do przycisków radiowych? O ile mogę powiedzieć, CakePHP pozwala tylko dodać te same (ograniczone) atrybuty do wszystkich przycisków radiowych w grupie.CakePHP - Jak dodać atrybuty do poszczególnych przycisków opcji?

Jakieś pomysły na generowanie tego, na przykład?

<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> 

Odpowiedz

-1

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

+0

Czy masz przykład, który generuje grupę przycisków radiowych z stowarzyszenia modelu? Czy możesz zrobić przykład, który generuje napisany przeze mnie HTML? – BadHorsie

0

Spróbuj tego:

$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); 
Powiązane problemy