Thursday, December 30, 2010

Re: Cakephp related tables show id's instead of values

Hi,

You mentioned that Candidate hasMany Qualificationlookup belongsTo Qualification. By default, while finding the record, the recursion level is 1. That's why Qualificationlookup data fetched automatically when you find a particular Candidate. So you need to do something like following in 'view candidate' action to get qualification name and also need to use Containable behavior

$this->Candidate->contain('Qualificationlookup.Qualification');
$candidateDetails = $this->Candidate->findById($id);

Now the $candidateDetails will have data something like

array(
    'Candidate' => array(..............<candidate-data-here>..............)
    'Qualificationlookup' => array(
                                       0 => array(
                                               <qualificationlookup-data-here>,
                                               'Qualification' => array(...............<qualification-data-here>................)
                                              )
)

After this, you need to modify the 'view' to display qualification name in 'related qualificationlookups' table.

Hope this helps.

Amit Badkas

PHP Applications for E-Biz: http://www.sanisoft.com



On Thu, Dec 30, 2010 at 4:16 AM, vauneen <vauneen@gmail.com> wrote:
Hi, i think i have all 'baked' all my relationships correctly but my
'related' table shows id's instead of values.

my db has 3 tables. candidates, qualificationlookups, qualifications.
qualificationlookups, links candidates to qualifications using the id
of the candidate and the id of the qualification.

in my view view, for 'candidates', i have a 'related
qualificationlookups' table. (generated by baking a candidate hasmany
qualificationlookups and a qualificationlookups belongsto candidate
relationship)

in my edit view, for 'qualificationlookups', i can correctly set up
the candidates and qualifications fields as dropdowns so i know
'qualificationlookups's relationships are fine.

So how do i ask cakephp to list the name of the qualification (from
'qualifications' table) in the 'related qualificationlookups' table on
a candidate's page?

i must be missing something...

could someone please point me in the right direction?

Thanks, Vauneen

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

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: