Tuesday, September 24, 2013

Re: Stuggling to save HABTM data from a FormHelper form

Please ensure that your data follows the following structure when saving HABTM data:

Array  (      [0] => Array          (              [Client] => Array                  (                      [id] => 12345                  )              [Security] => Array                  (                      [id] => ALLCMCT LX Equity                  )          )      [1] => Array          (              [Client] => Array                  (                      [id] => 12345                  )              [Security] => Array                  (                      [id] => APMKNTD LX Equity                  )          )
...

As can be seen in the CakePHP documentation http://book.cakephp.org/2.0/en/models/saving-your-data.html in section "Saving Related Model Data (HABTM)".

Enjoy, John

On Tuesday, 24 September 2013 16:55:34 UTC+3, Harry Grumbar wrote:
I've been wrangling an app with Cake and have got myself stuck with saving HABTM data. To save repeating myself here is the link to my StackOverflow question which I have yet to receive a solution.

Basically I have 2 models "Client" and "Security" (as in a financial security "asset").
So a "client" can have many "securities" and "securities" belong to many "clients". I made a table to link the models and set up the associations in the models. My code is in the link but in a form that edits both normal client data and linked data it just won't save the linked data.

Any help would be greatly appreciated.


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: