I am some what new to CakePHP and wanted some assistance in setting up a form in a CakePHP View.
I have Array in the following form:
Array ( [1] => B002I0HJZO [2] => B002I0HJzz [3] => B002I0HJccccccccc )
I want a form with 3 radio buttons (in this case) that goes to a custom method called test
You can do that with the
FormHelperclass.Example:
The key is to specify the “type”. CakePHP usually defaults to a
selectelement by default.The example above doesn’t use the “automagic” feature of CakePHP. If you retrieve the options in your controller using a
find('list')and the array is passed to the view in the plural form of the field name without the “_id” suffix (e.g. if the field is “option_id”, you should do$this->set('options', $this->Option->find('list');assuming that “Option” is the model name), then you shouldn’t need to specify the “options”, just the “type”To answer the second part of your question, to post to a different action (e.g. “test”), you need to specify the action when creating the form.
Example:
For more information, read the documentation