Thanks Ryan, I did wonder that before posting my issue yesterday...I
previously prefixed the 1 and 2 with 'reply', so the ids were reply1
and reply2, but to no avail... the code is below, the only change
being the prefix of 'reply' in the array creation. Please note, I've
reverted to the actual reply codes for male and female, 2520 and 2530
respectively, in place of 1 and 2, because I'm a little bemused by the
id cake has now given the inputs (see a little lower), guessing they
depend on the values in the $options array somehow? Where does the Pl
of MemberGenderPl come from? And why?:

$options = array();
$c = 0;
while ($c < count($question['Reply'])) {
    $options['reply'.$question['Reply'][$c]['id']] = $question['Reply']
[$c]['value'];
    $c++;
}

echo $this->Form->input($question['Question']['name'], array(
        'type' => 'radio',
        'class' => 'list required',
        'options' => $options
));

For info, the $options array looks like this after it's created:

Array ( [reply2520] => Male [reply2530] => Female )

This gives me:

<input type="radio" value="reply2520" class="list required"
id="MemberGenderPl" name="data[Member][gender]">
<label for="MemberGenderPl">Male</label>
<input type="radio" value="reply2530" class="list required"
id="MemberGenderPl" name="data[Member][gender]">
<label for="MemberGenderPl">Female</label></fieldset>

Obviously I can see that the $options array value reply2520 and
reply2530 are now set as the value of the inputs.

What I'm trying to achieve (with the real values of 2520 and 2530
instead of 1 and 2, and non-numeric ids) is this:

<input type="radio" value="2520" class="list required" id="reply2520"
name="data[Member][gender]">
<label for="reply2520">Male</label>
<input type="radio" value="2530" class="list required" id="reply2530"
name="data[Member][gender]">
<label for="reply2530">Female</label>

Any further help would be great...I just want the ux to be correct, by
the labels being clickable :/. This kind of thing is absolutely
straightforward without using cake $this->Form->input(s), but then I
lose the benefit of the save functionality etc...and I really wanna
get to the bottom of this. Loving cake in all respects except this.
Still think the issue is in the array - any advice anyone please?? I'm
thinking should the array read something like:

Array ( Array( [id] => reply2520, [value] => Male, [for] =>
reply2520), Array( [id] => reply2530, [value] => Female, [for] =>
reply2530)  )

but tried various versions of this without getting there...pretty sure
'for' is not correct for instance...etc etc. Tried lots of things
prior to posting here...and checked all documentation and other user's
issues etc, but no definitive answer, Surely it can't be that tricky?
Flummoxed...

Thanks in advance...

Dave



On Nov 1, 3:22 am, Ryan Schmidt <google-2...@ryandesign.com> wrote:
> On Oct 31, 2011, at 11:29, dave wrote:
>
> > What I want to achieve:
>
> > <input type="radio" value="1" class="list required" id="1"
> > name="data[Member][gender]">
> > <label for="1">Male</label>
> > <input type="radio" value="2" class="list required" id="2"
> > name="data[Member][gender]">
> > <label for="2">Female</label>
>
> For the record, "1" and "2" are not valid HTML IDs. IDs must begin with a 
> letter. Some browsers enforce this.

-- 
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
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to