CakePHP radio button example

cakephp radio buttons.png
Thanks Ronnie, for the example! It looks like this useful hint won’t appear in the cakephp documentation any time soon. I think is’t “nerdnoteworthy”:

echo $html->radio(
	'User/admin',
	array(
		'no' => 'No',
		'yes' => 'Yes'),
	null,
	array('value' => 'no')
);

16 Responses to “CakePHP radio button example”

  1. Abba Bryant says:

    Wow, way to use an example months old from an almost year old ticket posted for a version of cake that is out of date and no longer intended for use.

    A 1.2 example is:

    echo $form->input( 'User.admin',
    'type' => 'radio',
    'options' => array( 'Yes'=>'yes', 'No'=>'no' )
    ));

  2. plumpnation says:

    Er, Abba, did you check the date on this post. No. You didn’t. Did you.

  3. Slovinco says:

    I think he didn’t. Did he?

  4. I_am_me says:

    No he didn’t. Did he?

  5. Sean says:

    I don’t know. Did he?

  6. Filipe says:

    He didn’t. Did I?

  7. lusi says:

    u guys are funny…and yes, he didn’t check the date. so do I, did you ?

  8. Kiluminati says:

    I did, did anyone else?

  9. mati says:

    WTF!!
    you don’t have anything to do?. do you?

  10. Osman says:

    I don’t have do I?

  11. funnyass says:

    No you don’t. do you?

  12. Abba Bryant says:

    Wow, way to use an example years old from an almost three year old ticket posted for a version of cake that is out of date and no longer intended for use.

    A 1.3 example is:

    echo $this->Form->radio( ‘User.admin’, array( ‘Yes’=>’yes’, ‘No’=>’no’ ));

    (In all seriousness this blog was the top result for “cakephp radio” so I figured it should have the latest answer)

  13. nano says:

    If you want to set the default value in radio button in cakePHP 1.3

    You can use the pattern:
    radio(‘Model.field’, array(‘option1′=>’option1′, ‘option2′=>’option2′), array(‘default’=>’option2′, ‘legend’=>false)); ?>

    reference site:
    http://www.lost-in-code.com/programming/php-code/cakephp-form-radio-default-checked-value/

  14. prashant says:

    thanks Abba bryant

  15. jef says:

    Look at Abba Bryant, the cake radio input god. You search google for things you already know how to do.

Leave a Reply