Tuesday, November 1, 2011

Re: How to get related username in view?

debug() the database result array in your view, then you can check if the User data is there. If not you have to check the relationship in your model files. I would say there is no or a wrong relationship with the users table.

-flosky



Daniel <danwgrace@gmail.com> schrieb:
I have a categories view which shows related posts that belong to the
category. On the posts table there is a user_id which relates to a
username on the users table. I would like to display the username for
each post on the category view, but when I put $post['User']
['username'] into the ctp file I get an error message: "undefined
index: User"



--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

No comments: