Tuesday, December 30, 2008

Re: checkbox groups in cakephp 1.2

On Wed, Dec 31, 2008 at 12:53 AM, mike <mwu153@gmail.com> wrote:
>
> but I need something like this right?
> [data] => Array
> (
> [UsersEthnicity] => Array
> (
> [ethnicity_id] => 1
> [users_id] => 14,
>
>
> [ethnicity_id] => 2
> [users_id] => 14
> )
>
>
> [User] => Array
> (
> [age] => 21
> [about_me] => adfsadfs
> )
>
>
> )

You can't have multiple identical keys. But I'd think, if I'm reading
this correctly, that you'd want Ethnicity, not the join table.

[data] => Array
(
[Ethnicity] => Array
(
[0] => Array
(
[id] => 1
),
[1] => Array
(
[id] => 2
)
),
[User] => Array
(
[age] => 21
[about_me] => adfsadfs
)
)

You're providing a choice of several ethnicities, not relationships
between ethnicities and users, so your checkboxes should reflect
ethnicities. If the associations are set up properly, Cake will deal
with the join table. How do you have the model relations set up?

And you'll need to include User.id, as well, I suppose.

I don't that it's related (heh) but you should use the singular form
with foreign key names, ie user_id. The idea is that, while the table
contains many users, this user_id is unique.

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

No comments: