tags:

views:

1205

answers:

3

hi,

i am trying to create a Radio button using Cakephp like the one 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 so using Form helper.. Please suggest me..

+2  A: 

This might help,

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

For radio type input the 'separator' attribute can be used to inject 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') 
));?>

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>
Anand
+1. Why was this guy down voted? He takes the time to answer a question and you take points from him? If FormHelper::input() is not flexible enough, use FormHelper::radio(). If that is not flexible enough, write the HTML you need by hand. http://api.cakephp.org/class/form-helper#method-FormHelperradio
deizel
A: 

Does 'between' go between the label and the input?

A: 

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

Don Kirkby