CakePHP Radio Button Form Helper

I am trying to create a Radio button using Cakephp, like the one that the result should resemble like

<div data-attr="radio" id="1"> <label id="label1">Untitled1</label><br/> <input type="radio" value="option1" id="Radio11" name="Workexperience"/> <label for="Radio11">Option1</label> <input type="radio" value="option2" id="Radio12" name="Workexperience"/> <label for="Radio12">Option2</label> </div> 

how to generate using a form helper. Please suggest me ..

+3
source share
2 answers

This can help,

http://book.cakephp.org/view/189/Automagic-Form-Elements#options-before-options-between-options-separator-a-191

To enter the type of radio signal, the 'separator' attribute can be used to enter markup to separate each input / label pair.

Code view

 <?php echo $form->input('field', array( 'before' => '--before--', 'after' => '--after--', 'between' => '--between---', 'separator' => '--separator--', 'options' => array('1', '2'), 'type' => 'radio' ));?> 

Conclusion:

 <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> 
+12
source

It looks like $ form-> radio () should do what you need. I don’t know if it will look like your example.

+1
source

Source: https://habr.com/ru/post/1308813/


All Articles