Tuesday, April 28, 2009

Cleaner display of related data in baked views? displayField?

I started a project with a bunch of preliminary scaffolded views and
those were find for helping us through data structures and
relationships. They also all included some nice defaults -- would
show "name" by default for a foreign key "id" in index and "view"
views. But it was clear I had to move on from many of the scaffolded
views to be able to customize.

I have started to work with non-scaffolded, baked views and how I can
customize enogh starting with baked MVC. Not surprisingly, I see some
differences. For example, view and index views simply show (not very
meaningful) "id" for foreign keys, where I would like to display
"name". In the view.ctp I can take something like:

echo $testRecord['TestRecord']['space_id'];

and change it to:

echo $testRecord['Space']['name'];

but I foresee myself doing this all over the place.

Is there a more systematic way of doing this in a helper or
something. I was thinking that "displayField" would be the answer and
that baked views would default to "name" and/or "title" by default,
but it doesn't seem to be working that way.

Thanks!

Jim
--~--~---------~--~----~------------~-------~--~----~
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: