Welcome Guest, Not a member yet? Register   Sign In
dmz htmlform dropdown rendering
#2

[eluser]bEz[/eluser]
Including Fields from Deep Relationships

This method also supports deep relationships. You can only include columns from objects that are related by single relationships all the way. The default column prefix for deep relationships is to replace all forward slashes with underscores. You can still override this to be whatever you want.

A deep relationship is simply the name of each related object, in order, separated by a forward slash (/).

Here's an example:
Code:
// Create Post
$p = new Post();

// Include the user's name in the result:
$p->include_related('user', 'name');
// include the user's group's name in the result:
$p->include_related('user/group', 'name');
$p->get();  

foreach($p->all as $post) {
    echo("{$post->user_name} ({$post->user_group_name})\n");
}

So in your case, you would just need to do 'client/site/job' as your deep relationship.

Code:
$c = new Client();

// Include the client's site data in the result:
$c->include_related('site', 'name');
// include the site's job's data in the result:
$c->include_related('site/job', 'name');
$c->get();  

foreach($c->all as $client) {
    echo("{$client->site_name} ({$client->site_job_name})\n");
}

Of course, you would want to supply the "list" data for the form_fields parameter.


Messages In This Thread
dmz htmlform dropdown rendering - by El Forum - 12-02-2009, 04:57 AM
dmz htmlform dropdown rendering - by El Forum - 12-02-2009, 10:20 AM
dmz htmlform dropdown rendering - by El Forum - 12-03-2009, 05:01 AM



Theme © iAndrew 2016 - Forum software by © MyBB