Tuesday, January 1, 2013

Deleting Data From Other Model/Controller

Hi all,

I'm new to CakePHP and I could do with some newbie advice please.

I'm creating an invoicing application and the way I have it set up is with seperate tables (and so Models and Controlllers) for Invoices and Items. The Invoice table holds the data such as 'Invoice Number', 'Date' and  'Client ID' for example, and the Items table stores individual records/items that make up each invoice with 'Quantity', 'Unit Price' etc. The two are associated correctly.

When I call the 'edit' view for Invoices, obviously passing an ID, I retrieve the record and then also loop through the all associated records returned from the Items table to - all works as planned and are retrieved and displayed correctly.

What I want to be able to do from this view though, is to be able to delete individual items from the invoice by clicking on a delete button next to each - ideally with a confirmation box. How would this be acheived exactly? What would be the best method? Would I use a function in the Items controller to do this without leaving the page? How would I call the function in that controller from the Invoice controller/view? Or would another method such as the CakePHP query() function be used for this?

I hope I've explained this setup clearly enough for someone to offer any help and/or advice for which I would be very thankful.

Thanks in advance,

Adam

--
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: