The way I've worked around it for the moment is to add the following
to the add function in the controller:

                        if( !is_array($this->data['Person']['Person']) ) {
                                $this->data['Person']['Person'] = aa(0, 
$this->data['Person']
['Person']);
                        }

It's not pretty, I know.

On May 23, 3:18 pm, simon <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Oddly enough Cake doesn't seem to understand that it should make an
> entry in the join table for HABTM related models when the foreign key
> isn't supplied from a multi select field...
> Let me try and explain that :)
>
> Say you are creating a new Item which belongs to one or many Persons,
> you will need a select tag with the name "Person/Person". However it
> seems this needs to be a select tag with multiple selection enabled.
> This is so that the form generates the following:
>
> Array
> (
>     [Item] => Array
>         (
>             [field] => Value
>         )
>     [Person] => Array
>         (
>             [Person] => Array
>                 (
>                     [0] => 1
>                 )
>         )
> )
>
> In other words you can't use a normal select tag, as this will
> generate:
>     [Person] => Array
>         (
>             [Person] => 1
>         )
>
> As the value of person isn't an array here, Cake won't pick it up and
> won't make an entry in the join table.
>
> I haven't found a solution for this yet, I'm assuming that I'm either
> missing something or that I'm going to have to do some ugly hack in
> the controller's add/edit functions to turn the value into an array.
>
> Simon


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to