tags:

views:

142

answers:

2

i am generating dynamic multiple checkbox, how should i generate that and how should i manage that in cakephp?

+1  A: 

The checkboxes should look like this:

<input name="data[ModelName][ModelName][]" value="x" id="ModelNameModeNamex" /> your Text

I created a helper for this, that renders the checkboxes in a table. It was derived from this helper


EDIT The data will be submitted as an array, that the CakeMagic can deal with. For the default example Post <-habtm-> Tag an input field in the post-view should be

<input name="data[Tag][Tag][]" value="4" id="TagTag4" /> myTagName

when submitting the data and doing a save in the PostsController, Cake will also save the habtm association in the posts_tags table. If you are interested how exactely the data looks, simply place debug($this->data); in the PostsController


also, 2 comments:

  1. If you would like some help, please put some effort in formulating the question
  2. It might help if you would accept an answer once in a while
harpax
if all name check box name and id are same then how i get value of array when i submit form plz help me
dilip
A: 

Only the name attribute is really important, it decides how the data will be posted back. Getting the value of the array should be doable through $this->data or $this->params.

Mark Story