Hi,

I was wondering if anyone knew a neat way to use the html helper to
handle forms that allow for the adding/editing of a main model and it's
associated entries in a hasMany associated model.

For example, I have a Form model and a FormField model. the Form model
has a hasMany association set to FormField. I want to have a form that
allows me to edit the main Form details and also the FormField details
at the same time. When i read the data in my edit action method to
populate the edit form it comes back in the following format:

print_r($this->data)

[Form] => Array
(
    [id] => 1
    [title] => Test 1
)
[FormField] => Array
(
    [0] => Array
    (
        [id] => 1
        [form_id] => 1
        [label] => Test One
    )
    [1] => Array
    (
            [id] => 2
            [form_id] => 1
            [label] => Test Two
    )
)

For the main Form model I can of course use $html->input('Form/title')
to create input fields but I can't seem to find a way to create input
fields for the multiple FormField model entries.

I checked out the Input function in the helper class and found the
tagValue function that retrieves the field value from the data array.
It calls setFormTag that splits the label you supplied using the
forward slash, and sets the first part to be the model name and the
second part to be the field name. It then tries to retrieve the data
using:

$this->data[$this->model][$this->field]

So it looks like it can only handle two dimensions rather than the
three dimensions I require e.g.

$this->data[$this->model][$index][$this->field]

I just wanted to check if I was missing something and if anyone knew of
a way to handle this before I start writing my own code to handle it?
>From the brief section of the manual that talks about saving data for
hasMany associations it sounds like it is possible - I just can't seem
to find anything that shows you how, despide some exhaustive google
searching.

steve


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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