Re: Saving Multiple Models in one save
Hi since the saveAll method of cake only support upto one level, how can we save the data from one form into 4 models?? thanks. On Dec 25 2008, 5:22 am, Steven Wright rhythmicde...@gmail.com wrote: Thank you thank you. That was exactly what I was looking for. -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of Adriano Varoli Piazza Sent: Wednesday, December 24, 2008 8:05 AM To: CakePHP Subject: Re: Saving Multiple Models in onesave On 24 dic, 10:32, Steven Wright rhythmicde...@gmail.com wrote: What does the 0 do? Make it work :) Seriously, you can add multiple items in this fashion, such as Patrimonio.1.tipo, Patrimonio.2.tipo, etc., and they'll be saved in sequence from a single form. However, I doubt that this is the problem, I suspect more of an error in the definition of relationships between the models involved. For more meat, try this:http://teknoid.wordpress.com/2008/08/01/practical-use-of-saveall-part... ing-with-multiple-models/ -- Saludos, Adriano --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Saving Multiple Models in one save
Well sorry for not being prompt, Presently cakePHP supports saving models upto level one only. So I have changed my code accordingly. Thanks for your reply which was helpfull. Regards Sijo On Wed, Dec 10, 2008 at 2:52 PM, WebbedIT p...@webbedit.co.uk wrote: I haven't gotten around to using saveAll() as yet, but I did spot that you haven't created a belongsTo relation from SamplingDetail to Intimation to close the hasOne/belongsTo relationship between the two models. Similarly best practice dictates you should create hasOne relationships for Processor-SamplingDetail Contact-Processor Not that I think this will necessarily solve your saleAll issue but it is good practice to do so. Without using the saveAll function myserlf I can only hazard guesses at what you can look at. I tried looking for a recursive property to try and tell the function to go more than 1 level deep, but that doesn't exist. What happens if you change the fields from ?php echo $form-input('SamplingDetail.package_description'); ? ?php echo $form-input('SamplingDetail.lot_number'); ? ?php echo $form-input('SamplingDetail.invoice_number'); ? ?php echo $form-input ('SamplingDetail.Processor.Contact.firstName'); ? ?php echo $form-input ('SamplingDetail.Processor.Contact.address'); ? to ?php echo $form-input('SamplingDetail.package_description'); ? ?php echo $form-input('SamplingDetail.lot_number'); ? ?php echo $form-input('SamplingDetail.invoice_number'); ? ?php echo $form-input ('Contact.firstName'); ? ?php echo $form-input ('Contact.address'); ? The fact that Intimation model fields will save from ?php echo $form-input('Intimiation.field1'); ? And SamplingDetail fields will save from ?php echo $form-input('SamplingDetail.field2'); ? Means other related fields should save from ?php echo $form-input('Processor.field3'); ? ?php echo $form-input('Contact.field4'); ? Hopefully someone else can join in and clear this up ;) -- Sijo Jose Chakramakkil --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Saving Multiple Models in one save
In a similar situation, my add view looks like this: echo $form-label('Patrimonio.0.tipo', 'Label text:'); echo $form-text('Patrimonio.0.tipo'); Notice the 0. -- Saludos, Adriano --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
RE: Saving Multiple Models in one save
What does the 0 do? -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of Adriano Varoli Piazza Sent: Wednesday, December 24, 2008 7:26 AM To: CakePHP Subject: Re: Saving Multiple Models in one save In a similar situation, my add view looks like this: echo $form-label('Patrimonio.0.tipo', 'Label text:'); echo $form-text('Patrimonio.0.tipo'); Notice the 0. -- Saludos, Adriano --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Saving Multiple Models in one save
On 24 dic, 10:32, Steven Wright rhythmicde...@gmail.com wrote: What does the 0 do? Make it work :) Seriously, you can add multiple items in this fashion, such as Patrimonio.1.tipo, Patrimonio.2.tipo, etc., and they'll be saved in sequence from a single form. However, I doubt that this is the problem, I suspect more of an error in the definition of relationships between the models involved. For more meat, try this: http://teknoid.wordpress.com/2008/08/01/practical-use-of-saveall-part-1-working-with-multiple-models/ -- Saludos, Adriano --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
RE: Saving Multiple Models in one save
Thank you very much. -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of Adriano Varoli Piazza Sent: Wednesday, December 24, 2008 8:05 AM To: CakePHP Subject: Re: Saving Multiple Models in one save On 24 dic, 10:32, Steven Wright rhythmicde...@gmail.com wrote: What does the 0 do? Make it work :) Seriously, you can add multiple items in this fashion, such as Patrimonio.1.tipo, Patrimonio.2.tipo, etc., and they'll be saved in sequence from a single form. However, I doubt that this is the problem, I suspect more of an error in the definition of relationships between the models involved. For more meat, try this: http://teknoid.wordpress.com/2008/08/01/practical-use-of-saveall-part-1-work ing-with-multiple-models/ -- Saludos, Adriano --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
RE: Saving Multiple Models in one save
Thank you thank you. That was exactly what I was looking for. -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of Adriano Varoli Piazza Sent: Wednesday, December 24, 2008 8:05 AM To: CakePHP Subject: Re: Saving Multiple Models in one save On 24 dic, 10:32, Steven Wright rhythmicde...@gmail.com wrote: What does the 0 do? Make it work :) Seriously, you can add multiple items in this fashion, such as Patrimonio.1.tipo, Patrimonio.2.tipo, etc., and they'll be saved in sequence from a single form. However, I doubt that this is the problem, I suspect more of an error in the definition of relationships between the models involved. For more meat, try this: http://teknoid.wordpress.com/2008/08/01/practical-use-of-saveall-part-1-work ing-with-multiple-models/ -- Saludos, Adriano --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Saving Multiple Models in one save
I haven't gotten around to using saveAll() as yet, but I did spot that you haven't created a belongsTo relation from SamplingDetail to Intimation to close the hasOne/belongsTo relationship between the two models. Similarly best practice dictates you should create hasOne relationships for Processor-SamplingDetail Contact-Processor Not that I think this will necessarily solve your saleAll issue but it is good practice to do so. Without using the saveAll function myserlf I can only hazard guesses at what you can look at. I tried looking for a recursive property to try and tell the function to go more than 1 level deep, but that doesn't exist. What happens if you change the fields from ?php echo $form-input('SamplingDetail.package_description'); ? ?php echo $form-input('SamplingDetail.lot_number'); ? ?php echo $form-input('SamplingDetail.invoice_number'); ? ?php echo $form-input ('SamplingDetail.Processor.Contact.firstName'); ? ?php echo $form-input ('SamplingDetail.Processor.Contact.address'); ? to ?php echo $form-input('SamplingDetail.package_description'); ? ?php echo $form-input('SamplingDetail.lot_number'); ? ?php echo $form-input('SamplingDetail.invoice_number'); ? ?php echo $form-input ('Contact.firstName'); ? ?php echo $form-input ('Contact.address'); ? The fact that Intimation model fields will save from ?php echo $form-input('Intimiation.field1'); ? And SamplingDetail fields will save from ?php echo $form-input('SamplingDetail.field2'); ? Means other related fields should save from ?php echo $form-input('Processor.field3'); ? ?php echo $form-input('Contact.field4'); ? Hopefully someone else can join in and clear this up ;) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---