Hi all,
I am wondering how to model a query and an edit form in this case:
I have a table "workshop". Workshops can have many "description"s, and
each of those has a "category". So when I create or edit a workshop, I
want to be able to input workshop and description data into one form.
My problem is, that I always need to fetch all categories (to display
their names), even if I edit a workshop that has no description yet.
So when I do a query with

contain(array('Description' => 'Category'))

...I only get the category data when there already is a description.
Is there a possibility to form the find()-query so that I get my
desired result? Or do I have to do a seperate query like this:

$descriptions = $this->Workshop->Description->Category->find('all',
array(
        'contain' => array(
                'Description' => array(
                        'conditions' => array(
                                'workshop_id' => $id
                        )
                )
        )
));

and then attach the data to the workshop data?

And the second question is: does this work with automagic form
elements? Can I foreach() the categories in the view and create the
inputs for all descriptions?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to