Just a quick typo fix on that last statement...after the Soooooooooooooooooo....added the number 6 on the input id. That's how it should read...
<input type="radio" name="data[Member][field6]" id="MemberField6Yes" value="Y"> <label for="MemberField6Yes">Yes</label> <input type="radio" name="data[Member][field6]" id="MemberField6No" value="N"> <label for="MemberField6No">No</label></div> On Nov 3, 3:10 pm, dave <davespa...@gmail.com> wrote: > Hi... I posted a couple of days ago re making radio button labels > clickable...but guess my question was too long...and reading it back, > whilst accurate, it was pretty bloody boring too...sorry guys! > > (note after writing this...this too has become long - maybe not quite > as boring (I hope), but left me bamboozled.............) > > I've resorted to removing id from the input altogether as I think it's > better to have nothing take place at all when clicking a label rather > than the top radio button been selected irrespective of which label in > the group is clicked. > > However...can someone please explain this to me. I'd still like to > make radio labels clickable for the appropriate radio > button...*sighs*. > On this page:http://book.cakephp.org/view/1390/Automagic-Form-Elements > , about a third of the way down (second para in 7.3.3.3), is an > example of radio buttons with ---between--- text etc. Not really > interested in the --betweens-- or --afters-- etc. Am VERY interested > in the input ids and label fors however...as they seem to render as I > want them to be........... > > It looks like this: > > <?php echo $this->Form->input('field', array( > 'before' => '--before--', > 'after' => '--after--', > 'between' => '--between---', > 'separator' => '--separator--', > 'options' => array('1', '2') > ));?> > > And claims to output this (note the input->id and the label->for are > the same, thus rendering the labels clickable): > > Output: > > <div class="input"> > --before-- > <input name="data[User][field]" type="radio" value="1" > id="UserField1" /> > <label for="UserField1">1</label> > --separator-- > <input name="data[User][field]" type="radio" value="2" > id="UserField2" /> > <label for="UserField2">2</label> > --between--- > --after-- > </div> > > It doesn't do this for me. Firstly I had to add a type->radio, > otherwise I get a select...which is ok, I added 'type' => > 'radio'...but, and this is the frustrating bit...I see this being > generated: > > <div class="input radio"> > --before----between--- > <fieldset> > <legend>Field</legend> > <input type="hidden" name="data[Member][field]" > id="MemberField_" > value=""> > <input type="radio" name="data[Member][field]" > id="MemberField" > value="0"> > <label for="MemberField">1</label> > --separator-- > <input type="radio" name="data[Member][field]" > id="MemberField" > value="1"> > <label for="MemberField">2</label> > </fieldset> > --after-- > </div> > > I'm in my members controller here...hence the MemberField rather than > UserField, but that's all... > > See my input->ids and label->fors? All identical. Like peas in a pod. > Like things that are indistinguishable from each other. Like twins. > Like..like...like...pah! > > Any ideas?? If anyone can help, I'd be eternally grateful...well, for > a bit anyway. > > Thanks in advance > > Dave > > Ok, so this has become long too...and it's about to get longer... > > After more trial and error, I've managed to get the labels working, > with this format: > > echo $this->Form->input('field1', array( > 'type' => 'radio', > 'options' => array('Y'=>' Yes ','N' => ' No') > )); > > which gives: > <input type="radio" name="data[Member][field1]" id="MemberField1" > value="Y"> > <label for="MemberField1"> Yes </label> > <input type="radio" name="data[Member][field1]" id="MemberField1N" > value="N"> > <label for="MemberField1N"> No</label></div> > > (ie appends the N to the MemberField id. By no means ideal, but it > works.) > > ...but this doesn't work (changed N to M) > > echo $this->Form->input('field2', array( > 'type' => 'radio', > 'options' => array('Y'=>' Yes ','M' => ' No') > )); > > gives > <input type="radio" name="data[Member][field2]" id="MemberField2" > value="Y"> > <label for="MemberField2"> Yes </label> > <input type="radio" name="data[Member][field2]" id="MemberField2" > value="M"> > <label for="MemberField2"> No</label></div> > > ARRRRGGGGHHHH!!!! I tried a few more examples... > > echo $this->Form->input('field3', array( > 'legend' => false, > 'type' => 'radio', > 'options' => array('Y'=>' Yes ','A' => ' Ao') > )); > echo $this->Form->input('field4', array( > 'legend' => false, > 'type' => 'radio', > 'options' => array('Y'=>' Yes ','n' => ' no') > )); > echo $this->Form->input('field5', array( > 'legend' => false, > 'type' => 'radio', > 'options' => array('Y'=>' Yes ','m' => ' no') > )); > echo $this->Form->input('field6', array( > 'legend' => false, > 'type' => 'radio', > 'options' => array('Y'=>' Yes ','a' => ' ao') > )); > > AND WHAT HAPPENS? field3, 4 and 6 don't work, but, unbelievably field5 > does. > > For what its worth, here's the html generated by the 4 statements > above: > > <input type="radio" name="data[Member][field3]" id="MemberField3" > value="Y"> > <label for="MemberField3"> Yes </label> > <input type="radio" name="data[Member][field3]" id="MemberField3" > value="A"> > <label for="MemberField3"> Ao</label></div> > > <input type="radio" name="data[Member][field4]" id="MemberField4" > value="Y"> > <label for="MemberField4"> Yes </label> > <input type="radio" name="data[Member][field4]" id="MemberField4" > value="n"> > <label for="MemberField4"> no</label></div> > > <input type="radio" name="data[Member][field5]" id="MemberField5" > value="Y"> > <label for="MemberField5"> Yes </label> > <input type="radio" name="data[Member][field5]" id="MemberField5M" > value="m"> > <label for="MemberFid5M"> no</label></div> > > <input type="radio" name="data[Member][field6]" id="MemberField6" > value="Y"> > <label for="MemberField6"> Yes </label> > <input type="radio" name="data[Member][field6]" id="MemberField6" > value="a"> > <label for="MemberField6"> ao</label></div> > > Baffled... > > What I want to do is send: > > ...a value for the input id, > ...a value for the label 'for' (should be the same as the value for > the input id above) > ...a value for the value of the input (this could actually also be the > same as the above) > ...the text for the label > > in the $options array, and for cake to interpret these correctly. Is > that possible???? These are the 4 items associated with a group of > radio buttons that need to change for each radio button in the group > (in normal circumstances). Everything else remains constant (tho there > isn't much else anyway really...just the input type and name). > > Soooooooooooooo...by sending ('Y'=>'Yes','N' => 'No') I want to see: > > <input type="radio" name="data[Member][field6]" id="MemberFieldYes" > value="Y"> > <label for="MemberField6Yes">Yes</label> > <input type="radio" name="data[Member][field6]" id="MemberFieldNo" > value="N"> > <label for="MemberField6No">No</label></div> > > Surely that's reasonable isn't it??? > > Thanks > > Dave (just about hanging on to the furthest end of his tether...) -- 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