About Cake (Cakebakers, please read)

You may or may not know that I’m terribly busy at work at the moment, rewriting a large application that has its roots in PHP3 (oh yeah) and is a crazy mix of HTML and PHP. Things like ‘abstraction’, ‘layers’, or even just ‘separating code and presentation’ are completely alien concepts there.

So I decided to do the rewrite using one of the many PHP frameworks – CodeIgniter, CakePHP, Symfony, etc. – and decided on CakePHP (and, maybe more important, against Symfony). Doing the ‘reading’ parts of the app was simple enough, despite me being a complete newbie to CakePHP and using the 1.2 alpha versions which is mostly undocumented. But the actual data input and saving part, I hit a wall. Hard.

The problem I have is this (models are in bold):

To enter a Venue, you first select a Location. Then you add the Venue data, which is a lot of fields. Then, you add 0..n Images (which you upload just then). Then, 0..n Organs (as in music), either from a list of existing ones, or you can add one on the fly. Then, optionally, Ensembles (dito); and then you finally get to review your data and finalize the Transaction. All this should be on a wizard-like form, with multiple steps/pages.

Editing a venue is pretty much the same, except the data is already there. So the record and all associated records get copied as needed, with a reference to the original.

Then, the admin can either approve your Transaction and merge your changes into the DB, or deny it and delete the Transaction and all associated rows.

The problems start with getting everything wizard-like. There is a FormWizard component, but that seems to randomly overwrite or clear $this->data. I don’t know what to do with my data when I hit the ‘add 0..n images’ step, or when adding organs or ensembles. I have no clue what “the Cake way” would be here, since all examples I can find are rather simplistic with only a few fields, all on one page, and at most one relation (which always fits a select box).

Can any cake baker out there help me get back on track before I lose my mind?

One Reply to “About Cake (Cakebakers, please read)”

  1. Wow…that is one workflow problem that I’m glad isn’t mine 🙂 And PHP3 – I’ve never even seen PHP3 code 😉

    Multiple model input in one view comes op on the Google group all the time.
    Here are a couple of links for multiple model inputs in one view.
    http://groups.google.com/group/cake-php/browse_thread/thread/96d63ddd1fa4c91c
    http://groups.google.com/group/cake-php/browse_thread/thread/bbaab36f15fb517c

    There was a FileUpload Behavior on the Bakery but it is missing for some reason.

    The FormWizard was written for CakePHP1.1 so it is not unexpected that you ran into troubles with using it in 1.2. My suggestion is use the session component until the final step, then save it all to a pending table or state or whatever is required.

    Getting it “Wizard like” might be as simple as leaving a breadcrumb or using tabs so that you can flick between the different input areas.

    In future, you might want to post problems like this to the Google Group – there are some very helpful and knowledgeable people that read it.

    Good luck with your app. 🙂

Comments are closed.