Making a Radio/Checkbox Inputs with CakePHP
While this was easy after I figured it out, I found it particularly annoying that there was not an easily found how-to on how to do this. By default, CakePHP displays a many-to-one as a select drop down, and a many-to-many relationship as a multiselect (which I very rarely use or see used in form design).
Switching the many-to-one to a radio button is fairly easy. You do this like so:
// // Display a many-to-one as a radio // echo $form->input('your-many-to-one-attribute', array('type'=>'radio'));
You can do a many-to-many with checkboxes in this slightly unintuitive manner as well:
// // Display a many-to-many as checkboxes // echo $form->input('your-many-to-many-attribute',array( 'type' => 'select', 'multiple' => 'checkbox'));
One Response to “Making a Radio/Checkbox Inputs with CakePHP”
Interesting and informative. But will you write about this one more?
Leave a Reply