CakePHP: HABTM with hidden input tags
If you’re setting the IDs for a HABTM relationship in a hidden input tag to stop the user choosing the ID (I said user, not hacker - use proper AXOs to stop them!) you need to do set the name attribute to “data[Model][Model][]” NOT “data[Model][Model]”. So you can’t use the HTML Helper, you have to output the raw HTML (how last decade!)
Or just do $this->data[’Model’][’Model’] = array($id); before you save().
Applies to CakePHP 1.1, may not be relevant to 1.2.
↑ Back to Top | Textarea: Larger | Smaller