Hi,
Your HABTM save will be handled automatically by Cake if you pass an
array of ids to be added to the association.

The naming convention for the form field is
data[AssociationName][AssociationName][], which in your case would be
data[ServiceManager][ServiceManager][]

Note the empty square brackets on the end - in PHP that converts the
data sent to an array of items.

I don't think the HTML helper provides any automated way of generating
field names in this format -  apart from using a multiple select box
(which I think has usability problems, I prefer checkboxes)

I found a CheckBoxGroup function at this discussion which I adapted
into my own extended version of the HTML helper - which works fine:
http://groups.google.com/group/cake-php/browse_thread/thread/526445d178480c8d/#

Note: the full array of associations should be included as this
automation will remove any pre-existing HABTM save.

Also, if you are using checkboxes and have selected nothing, nothing
will be updated, unless you set the value of your
data[ServiceManager][ServiceManager] to an empty array before saving.

As far as I know there is no automated way to add/remove  individual
HABTM relationships between models one at a time - and you need to
execute some custom SQL, or define your relationships as Models in
their own right, which gives them more flexibility. .


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to