My default radio inputs are like this
$this->Form->radio('email_notifications', ['one','two']);
I have this in default:
<input type="radio" id="usertype-0" value="0" name="userType">
<label for="email-notifications-0">one</label>
And need to rephrase this structure to:
<label class="radio" for="usertype-0">
<input type="radio" id="usertype-0" value="0" name="userType">one
</label>
Had tried with custom templates. It works fine with 'inputContainer', but not 'radioContainer'. Had used the following to test, by adding a div for radio buttons:
$this->Form->templates([
'radioContainer' => '<label {{attrs}}">{{input}}{{text}}</div>'
]);
But nothing work for me as I get only the default structure. Am I doing someway wrong? I tried to configure with reference to this too: Cakephp 3 multiple custom template formhelpers
I'm not sure what makes you think there would be a template named
radioContainer
, maybe this existed in earlier versions? The radio element related templates areradio
andradioWrapper
.Anyways, the default output looks different to what you are showing, by default radio elements are nested in label elements, ie exactly what you are looking for according to your sample code.
This
will generate the following HTML (indentations and linebreaks added by me)
So the fix should be to update to the latest (dev) version.