0

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

2 Answers 2

3

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
1
  • if all name check box name and id are same then how i get value of array when i submit form plz help me Mar 19, 2010 at 6:53
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.