Why are you trying to save to the relationship table? Cake will do
that for you automatically.

What does your view look like (at least the part that creates the
form)? Provided your HABTM is set up correctly in the models and view,
calling $this->Model->save($this->data) in the controller should be
sufficient.

On Apr 5, 9:12 am, tricky999 <param3...@googlemail.com> wrote:
> I'll apologise now! There seems to be loads of advice about HABTM in
> cake, but I still can't quite get the answer to my particular problem.
>
> I have two tables and a join_table.  On my view, I have created a
> form, which has a multiple checkbox.  The problem I am having is that
> this is not returned in a format that I can save it in.
>
> Using debug($this->data), I get this returned to my edit action:
>
> Array
> (
>     [PortfolioEntry] => Array
>         (
>             [id] => 78
>             [when] => Array
>                 (
>                     [day] => 04
>                     [month] => 04
>                     [year] => 2010
>                 )
>
>             [title] => Another test
>             [description] => Hmmmm, will this work I wonder?  It
> might, although if you do not include full stops it doesn't!
>             [benefit] => Hello mucker.
>             [activity_id] => 2
>         )
>
>     [KsfDimensionsPortfolioEntry] => Array
>         (
>             [portfolio_entry_id] => 78
>             [ksf_dimension_id] => Array
>                 (
>                     [0] => 36
>                     [1] => 37
>                     [2] => 38
>                     [3] => 39
>                 )
>
>         )
>
> )
>
> The PortfolioEntry bit is saved absolutely fine, however, when I try
> to update the join_table with the KsfDimensionsPortfolioEntry part, I
> get an SQL error, since the ksf_dimension_id is an array.
> I am pretty sure that this array should be something like:
>
> [KsfDimensionsPortfolioEntry] => Array
>         (
>            [0] => array(
>                       [portfolio_entry_id] => 78
>                       [ksf_dimension_id] => 36
>             (
>             [1] => array(
>                       [portfolio_entry_id] => 78
>                       [ksf_dimension_id] => 36
>             )
>       etc....
>
> but I can't for the life of me come up with a 'cake' way of doing it!
> Any assistance would be gratefully received.
>
> Cheers.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to