Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

Radio button in CakePHP 1.1/1.2/1.3

Hello Friends,

Are you facing a problem in radio button when you are working woth CakePHP 1.3 ? Today i was working with Radio button in CakePHP 1.3 and i face some difficulty in showing radio button, remove hidden option and show selected radio button.I found little syntax change in CakePHP 1.3. Here i am showing you how to show radio button with CakePHP 1.3.

$options=array('Female'=>'Female','Male'=>'Male');
$attributes = array('legend'=>false,'value'=>'Female');
echo $form->radio('gender',$options,$attributes);

 

By default, Radio elements are wrapped with a label and fieldset. If you want to remove this than set legend attribute to false. Now if by default radio button will generate hidden element automatically. If you don't want that hidden element than show any of the radio button selected. You can make the radio button selected by giving the element value in value attribute. Look at above code. If you find any problem in this than let me know by comment.

Share:

15 Comments

Leave a Reply

Your email address will not be published.