So I've managed to get saveAssociated to work as intended with option 'deep' => true, based on the Book's model requirements for this method I was able to construct the View properly (took me awhile). As of now, if I change the form's file fields to standard text fields, everything works as expected and all records are saved. As soon as I change those form fields to file fields, it breaks.
I've tried using Miles Johnson's (now deprecated) Uploader plugin without success. After that didn't work I am now trying to get Jose Gonzalez's Upload plugin to work (github.com/josegonzalez/cakephp-upload). Unfortunately I'm coming across the same exact problem.
My primary application is rather large, but due to the issues I've had, I created a new project with only the required models and fields needed to get a very simple solution working. For that test solution (everything working except upload), the following is how it is configured.
MODELS:
Ticket
-> hasMany TicketResponse
TicketResponse
-> belongsTo Ticket
-> hasMany TicketAttachment
TicketAttachment
-> belongsTo TicketResponse
Ticket fields: id, title, created
TicketResponse fields: id, ticket_id, created, content
TicketAttachment fields: id, ticket_response_id, filename, location, filesize
Files for Recreation of App (if helpful)
DB schema: http://pastebin.com/XuwSCnHp
Models:
Ticket: http://pastebin.com/xRvU7Hhk
TicketResponse: http://pastebin.com/1CvdA68w
TicketAttachment: http://pastebin.com/xSajRhJD
All of the controllers/views/models were originally created from the cake bake template. The only changes were to the models (fixing associations for saveAssociated to work, plugin/behavior settings, validation changes), the Ticket view add.ctp, and the ticket controller.
Ticket View "add.ctp": http://pastebin.com/sSxh7Wps
TicketController.php: http://pastebin.com/2n2jVtpg
(NOTE: The Upload plugin would also need to be downloaded and configured (bootstrap.php), and the Session Component and Helper would need to be added to AppController as well.
I'm running CakePHP v2.5.3 on this example project. I've upgraded my older project from 2.1 in order to try to solve my problems, but nothing seems to be working with regard to the upload. :(
Also, I have a CakeLog::write call in the TicketAttachment model file. I *believe* the method calling that should be called from the Upload behavior, but it's never reached. In fact, I tried a CakeLog::write from within the Upload behavior's `setup()` method and it too did not write anything to the debug log. I'm stumped. I don't know if the Upload behavior just isn't loading properly, or if I've done something else improperly.
After changing the text fields to file upload fields, the form just isn't saving, providing only the generic message that the ticket could not be saved. Before switching from the Uploader behavior to the Upload behavior, when I switched from text to file upload fields I was getting an error that a field of type array was an incorrect value (or something along those lines), so I *suspect* that the Upload behavior is loaded and instantiated, but I do not know how to properly validate this theory.
Any help would be greatly appreciated!
-- I've tried using Miles Johnson's (now deprecated) Uploader plugin without success. After that didn't work I am now trying to get Jose Gonzalez's Upload plugin to work (github.com/josegonzalez/cakephp-upload). Unfortunately I'm coming across the same exact problem.
My primary application is rather large, but due to the issues I've had, I created a new project with only the required models and fields needed to get a very simple solution working. For that test solution (everything working except upload), the following is how it is configured.
MODELS:
Ticket
-> hasMany TicketResponse
TicketResponse
-> belongsTo Ticket
-> hasMany TicketAttachment
TicketAttachment
-> belongsTo TicketResponse
Ticket fields: id, title, created
TicketResponse fields: id, ticket_id, created, content
TicketAttachment fields: id, ticket_response_id, filename, location, filesize
Files for Recreation of App (if helpful)
DB schema: http://pastebin.com/XuwSCnHp
Models:
Ticket: http://pastebin.com/xRvU7Hhk
TicketResponse: http://pastebin.com/1CvdA68w
TicketAttachment: http://pastebin.com/xSajRhJD
All of the controllers/views/models were originally created from the cake bake template. The only changes were to the models (fixing associations for saveAssociated to work, plugin/behavior settings, validation changes), the Ticket view add.ctp, and the ticket controller.
Ticket View "add.ctp": http://pastebin.com/sSxh7Wps
TicketController.php: http://pastebin.com/2n2jVtpg
(NOTE: The Upload plugin would also need to be downloaded and configured (bootstrap.php), and the Session Component and Helper would need to be added to AppController as well.
I'm running CakePHP v2.5.3 on this example project. I've upgraded my older project from 2.1 in order to try to solve my problems, but nothing seems to be working with regard to the upload. :(
Also, I have a CakeLog::write call in the TicketAttachment model file. I *believe* the method calling that should be called from the Upload behavior, but it's never reached. In fact, I tried a CakeLog::write from within the Upload behavior's `setup()` method and it too did not write anything to the debug log. I'm stumped. I don't know if the Upload behavior just isn't loading properly, or if I've done something else improperly.
After changing the text fields to file upload fields, the form just isn't saving, providing only the generic message that the ticket could not be saved. Before switching from the Uploader behavior to the Upload behavior, when I switched from text to file upload fields I was getting an error that a field of type array was an incorrect value (or something along those lines), so I *suspect* that the Upload behavior is loaded and instantiated, but I do not know how to properly validate this theory.
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/d/optout.
No comments:
Post a Comment