Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Multiple form_radio with our label
  • Hello,

    I want to put multiple input_radio with our label in my form. But, if I use the Form::radio() method, and that I watch the code generated, I've all my labels with the "for" attribute pointed to only my first radio input.

    How can I do to have first label pointed to first radio input, second to second, etc. ?
  • The name of the radio button elements in a radio group should always be the same, so you can't use it in the label to reference it.

    You should pass an 'id' in the attributes of each radio button, and use the id in the "for" attribute of the label.

    Something you need to do anyway, because by default it generates "form_" + fieldname as the id, which gives all radio buttons in the group the same id too, and that is invalid HTML.

    Alternative is to embed the radio button in the label text.

    See http://stackoverflow.com/questions/4684382/radio-groups-with-clickable-label
  • Yes I've seen the generated id of the inputs.

    I've embedded the radio buttons in the labels.

    Thank you !

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion