see this great article in bakery
http://bakery.cakephp.org/articles/view/create-multiple-checkboxes-instead-of-a-multiple-select-in-your-views


On Nov 14, 6:28 pm, Langdon Stevenson <[EMAIL PROTECTED]>
wrote:
> Hi Daniel
>
> My solution to this problem (when using check boxes with HABTM
> relationships) is to test the data coming back to the controller.  If
> there is no array for (in your case) Services, then I would add an empty
> array called Services.
>
> This will force Cake to delete all of the relationships in the join table.
>
> Regards,
> Langdon
>
> DGPhoebus wrote:
> > Using Cake 1.2.0.5875 pre-beta, have two tables.... Islands, Services
> > (Concierge Services), and a join table islands_services.  Services are
> > presented as a list of checkboxes.  When an island is updated the post
> > data contains this:
>
> > Array
> > (
> >     [Island] => Array
> >         (
>
> >         )
> >     [Service] => Array
> >         (
> >                [Service] =>
> >                       (
> >                       )
> >         )
> > )
>
> > And obviously inside the arrays is the post data.   What I am finding
> > is that upon calling $this->Island->save($this->data), if all services
> > are "unchecked" (essentially "remove" all services from an island
> > definition) the post data now looks like this:
>
> > Array
> > (
> >     [Island] => Array
> >         (
>
> >         )
> > )
>
> > But upon calling $this->Island->save($this->data) the join table is
> > not updated (all related rows are not deleted).  [Service] must be
> > present in the post data for the Model to update the join table.  So I
> > have hacked it and I test to see if that array exists in the post data
> > and if not I add it.... which then causes the join table to be updated
> > correctly.  Just wondering if this is a bug... cause the alpha release
> > didn't work like this....
>
> > Thanks all.
>
> > Daniel

--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to