Tuesday, December 22, 2009

RE: 3 Days and not 1 person has any idea?

So I have my checkboxes displaying but still no luck populating them.

My data comes back as:

[ProfileSkill] => Array
(
[0] => Array
(
[id] => 1
[profile_id] => 4b315740-8bc0-433d-a377-34554adcd75b
[skill_id] => 1
[year_id] => 2
)

[1] => Array
(
[id] => 2
[profile_id] => 4b315740-8bc0-433d-a377-34554adcd75b
[skill_id] => 2
[year_id] => 2
)

[2] => Array
(
[id] => 3
[profile_id] => 4b315740-8bc0-433d-a377-34554adcd75b
[skill_id] => 3
[year_id] => 3
)

[3] => Array
(
[id] => 4
[profile_id] => 4b315740-8bc0-433d-a377-34554adcd75b
[skill_id] => 4
[year_id] => 1
)

)
($selections is my list I grab from the db)
My list comes back:

Array
(
[1] => Something
[2] => Test
[3] => Filler
[4] => Junk
[5] => Something Else
[6] => Working
[7] => Not Working
)

So to build my checklist manually before I add in my extra input I have in
the forn / view:

<?php
foreach ($selections as $key => $value)
{

echo $form->input('Profile.ProfileSkill.'.$key.'.skill_id',
array('type' => 'checkbox', 'label' => $value, 'value' => $key));
}
?>

Which outputs:

<div class="input checkbox"><input type="hidden"
name="data[Profile][ProfileSkill][1][skill_id]"
id="ProfileProfileSkill1SkillId_" value="0" /><input type="checkbox"
name="data[Profile][ProfileSkill][1][skill_id]" value="1"
id="ProfileProfileSkill1SkillId" /><label
for="ProfileProfileSkill1SkillId">Something</label>

Repeated for each $selection

It has to be in my echo
$form->input('Profile.ProfileSkill.'.$key.'.skill_id', array('type' =>
'checkbox', 'label' => $value, 'value' => $key)); keying of the array is my
only guess but nothing I do works.

Anyone see where I have gone wrong here?

I need every checkbox to show up and ones the user selected to be
pre-checked.

Thanks for your patience with me.

Dave

-----Original Message-----
From: cake-php@googlegroups.com [mailto:cake-php@googlegroups.com] On Behalf
Of AD7six
Sent: December-22-09 5:42 AM
To: CakePHP
Subject: Re: 3 Days and not 1 person has any idea?

On 21 dic, 22:05, "Dave" <make.cake.b...@gmail.com> wrote:
> Thanks John,
>
> That's correct what I am trying to do as you stated.
>
> HABTM Structure
> Profile
>         id
>
> Skill
>         id
>         name
>
> profile_skill
>         profile_id
>         skill_id
>         year <- this is my new aded field
>

IMO your whole problem stems from trying to refer to a model as a join
table. When a join table has more than 2 fields - make it a model. If you
give profile_skill a primary key, create a model for it, define Profile
hasMany ProfileSkill etc. you've find your difficulties pretty much
dissolve.

hth,

AD

Check out the new CakePHP Questions site http://cakeqs.org and help others
with their CakePHP related questions.

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
cake-php+at http://groups.google.com/group/cake-php?hl=en
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.717 / Virus Database: 270.14.114/2575 - Release Date: 12/21/09
15:43:00

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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: