How to put radio input outside of label element?

Hi,

is it possible to move radio inputs outside of their labels with $this->Form->radio() method?

So instead of:

<input type="hidden" name="favorite_color" value="">
<label for="favorite-color-r">
    <input type="radio" name="favorite_color" value="r" style="color:red;" id="favorite-color-r">
    Red
</label>

do:

<input type="hidden" name="favorite_color" value="">
<input type="radio" name="favorite_color" value="r" style="color:red;" id="favorite-color-r">
<label for="favorite-color-r">Red</label>

I am using latest CakePHP from 3.1 branch.

Yes, you will want to look into customizing the control template.

Review: https://book.cakephp.org/3.0/en/views/helpers/form.html#customizing-the-templates-formhelper-uses

You can also use non-control Form methods so only the field is output. The first is just a textarea, the second is the whole thing. If you use the first method you can make your own label tags.

Blockquote
echo $this->Form->textarea(‘notes’, [‘escape’ => false]);
// OR…
echo $this->Form->control(‘notes’, [‘type’ => ‘textarea’, ‘escape’ => false]);

Hi, thank you for your hints.

Unfortunatelly I couldn’t achieve desired effect by customizing templates etc. It was possible for checkbox only where I have that template: ‘checkboxFormGroup’ => ‘{{input}}{{label}}’, but not for radio. For radio template ‘radioFormGroup’ doesn’t exists.

I solved my problem manually with HTML.