Re: HABTM save problem
Thanks for the tip Mariano, actually I found the answer in your blog, I leave the post for the guys who might need it: http://www.cricava.com/blogs/index.php?blog=6&p=192&more=1&c=1&tb=1&pb=1#more192 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
RE: HABTM save problem
Since you seem to be a spanish speaker (I mean because of your name), take a look at this thread at the CakePHP spanish google group: http://groups.google.com/group/CakePHP-es/browse_thread/thread/c65e6cb2e1cf3 3e1/1c4e3957274e31b7#1c4e3957274e31b7 -MI --- Remember, smart coders answer ten questions for every question they ask. So be smart, be cool, and share your knowledge. BAKE ON! blog: http://www.MarianoIglesias.com.ar -Mensaje original- De: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] En nombre de [EMAIL PROTECTED] Enviado el: Viernes, 27 de Abril de 2007 08:23 p.m. Para: Cake PHP Asunto: HABTM save problem I'm new to cakePHP and I'm trying to try a HABTM insert into database but it's not working, this is what I got: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~--~~~~--~~--~--~---
Re: HABTM save problem
Thank you VERY much :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: HABTM save problem
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 cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---