> Hey,
>
> I am having a problem with my radio inputs and the corresponding
> labels.
> My code looks like this:
> <?
>  echo $form->radio('Model.0.fieldName', array('1' => 'Value1', '2' =>
> 'Value2', '3' => 'Value3'));
> ?>
>
> What I get as a result is
> <input type="radio" value="1" id="Model0FieldName"><label
> for="Model0FieldName">Value1</label>
> <input type="radio" value="2" id="Model0FieldName"><label
> for="Model0FieldName">Value2</label>
> <input type="radio" value="3" id="Model0FieldName"><label
> for="Model0FieldName">Value3</label>
>
> What I am expecting to get is rather "Model0FieldName1" as "id" and
> "for" attribute (with the value added) so I could click on each label
> to select the radio button.
>
> Does anyone have an idea what I am doing wrong? Since the code is
> quite simple I don't know where else to look for the error.

you just need to loose the .0.

<?php
 echo $form->radio('Model.fieldName', array('1' => 'Value1', '2' =>
'Value2', '3' => 'Value3'));
?>

which produces

<fieldset><legend>FieldName</legend><input type="hidden" value=""
id="ModelFieldName_" name="data[Model][fieldName]"><input type="radio"
value="1" id="ModelFieldName1" name="data[Model][fieldName]"><label
for="ModelFieldName1">Value1</label><input type="radio" value="2"
id="ModelFieldName2" name="data[Model][fieldName]"><label
for="ModelFieldName2">Value2</label><input type="radio" value="3"
id="ModelFieldName3" name="data[Model][fieldName]"><label
for="ModelFieldName3">Value3</label></fieldset>

which is what you are after.








-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to