Re: how to set "CHECKED" with form helper radio
>adam, I know it's array and if you see my first post I had set array already. >Miles J Thanks, Miles J OK, I try to use $form->input() Probably if i use $form->input() then if there is error the info user enter is still there? except the one invalid value?? I've been using $form->text style and if there is an error all the info I entered gone :( I was wandering how should I fix this issue. thanks, Leaf child On Aug 1, 1:23 pm, Miles J wrote: > $form->input() should always be used to build your forms. If you use > input(), the $data from your controller will automatically populate > these form fields if not empty. If you use radio() or something else, > it will not. So just use input() and pass the type option. > > And to answer your problem, just change the type to radio? > > $form->input('Test.test', array('type' => 'radio', 'options' => > $radio_btn, 'value' => 1, 'multiple' => true)); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: how to set "CHECKED" with form helper radio
$form->input() should always be used to build your forms. If you use input(), the $data from your controller will automatically populate these form fields if not empty. If you use radio() or something else, it will not. So just use input() and pass the type option. And to answer your problem, just change the type to radio? $form->input('Test.test', array('type' => 'radio', 'options' => $radio_btn, 'value' => 1, 'multiple' => true)); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: how to set "CHECKED" with form helper radio
Don't use his code exactly. $radio_btn is an array of the options for the. Unless you make the array, leave that part out Adam On Jul 31, 1:53 pm, leafchild wrote: > Thank you, Miles for your comment. > > sometimes I'm confused which one I should use. > I thought I should use form helper instead of html helper. > Also your example is mixed with 'checkbox', I want to use radio botton > not checkbox. > I tried your code just in case but I got an error. > > thanks, > > On Jul 30, 12:45 pm, Miles J wrote: > > > Do not use $form->radio(), you should be using $form->input(). > > > $form->input('Test.test', array('type' => 'checkbox', 'options' => > > $radio_btn, 'value' => 1)); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: how to set "CHECKED" with form helper radio
Thank you, Miles for your comment. sometimes I'm confused which one I should use. I thought I should use form helper instead of html helper. Also your example is mixed with 'checkbox', I want to use radio botton not checkbox. I tried your code just in case but I got an error. thanks, On Jul 30, 12:45 pm, Miles J wrote: > Do not use $form->radio(), you should be using $form->input(). > > $form->input('Test.test', array('type' => 'checkbox', 'options' => > $radio_btn, 'value' => 1)); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: how to set "CHECKED" with form helper radio
Do not use $form->radio(), you should be using $form->input(). $form->input('Test.test', array('type' => 'checkbox', 'options' => $radio_btn, 'value' => 1)); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
how to set "CHECKED" with form helper radio
If I use form helper to create radio button, how can I set "CHECKED"? For example, if I do like this, where I can set "CHECKED" if I want to? $radio_btn = array("1"=>"Yes", "0"=>"No"); echo $form->radio("Test.test", $radio_btn ); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---