Page 1 of 1
How to get related records in delegate class?

Posted:
Mon Feb 01, 2010 11:35 am
by kevinwen
I defined a relationship with songs table in artists table's relationships.ini, so there is a songs tab appears next to edit tab. Now I want to get all related songs for a specific artist in one of after_action_edit trigger. Can I use df_query() to get those related records? How? Is there any other way to do the same thing besides df_query()? thanks.
Re: How to get related records in delegate class?

Posted:
Tue Feb 02, 2010 7:40 pm
by 00Davo
Sure. Assuming you've got the record object as $record...
- Code: Select all
$songs = $record->getRelatedRecordObjects("Songs"); // array of objects
//alternately
$songs = $record->getRelatedRecords("Songs"); //array of arrays
Should work just fine.

Re: How to get related records in delegate class?

Posted:
Thu Feb 04, 2010 12:12 pm
by shannah
One caveat is that getRelatedRecords and getRelatedRecordObjects return only the first 30 rows by default (for your safety). You can control how many rows are returned by adding some additional parameters:
Check out more about these at
http://dataface.weblite.ca/getRelatedRecordsor
http://dataface.weblite.ca/getRelatedRecordObjectsAnother useful function is
numRelatedRecords
http://dataface.weblite.ca/numRelatedRecords
Re: How to get related records in delegate class?

Posted:
Sun Feb 07, 2010 8:42 pm
by kevinwen
Thank you so much. There is another question further: What delegate method can we use for the related records, like those __pullVale(), block__after_new_record_form() for the current table's records? I need to do something in the new/edit related record form? Thanks.
Re: How to get related records in delegate class?

Posted:
Mon Feb 08, 2010 12:26 pm
by shannah
The related record form just uses the same blocks as on the regular new/edit form.
Re: How to get related records in delegate class?

Posted:
Mon Feb 08, 2010 5:46 pm
by kevinwen
If I want to output some javascript using block__after_new_record_form(), which delegate class should I put this function into?
Re: How to get related records in delegate class?

Posted:
Mon Feb 08, 2010 5:58 pm
by shannah
The best way to see what blocks are available is to set
- Code: Select all
debug=1
at the beginning of the conf.ini file. Then load the form you want to modify. It will print out all of the blocks and slots on the page.
-Steve