i'm puzzled about something...
i created the situation as described here:
http://framework.weblite.ca/documentation/tutorial/getting_started/valuelists
under Example 3: Dynamic Valuelists based on the results of SQL queries
in the example the course table still has just a programid field (the linktable programcourses does not exist yet)
in the course fields.ini i put :
[ProgramID]
widget:type = select
vocabulary = programs
then, for debugging purposes, instead of putting the vocabulary query in the valuelists.ini , i put it in the course delegate (that would yield exacly the same result right?)
this is the vocabulary function:
function valuelist__programs() {
$app =& Dataface_Application::getInstance();
$record =& $app->getRecord();
$out = array();
if ($record and $record->_table->tablename == 'course' ) {
$qstring = "select ProgramID, ProgramName from Program order by ProgramName";
$res = mysql_query($qstring, df_db());
while ($row = mysql_fetch_assoc($res) ) $out[$row['ProgramID']] = $row['ProgramName'];
}
return $out;
}
then i went into the debugger and set a breakpoint in this function.
then i went to the listview of the table course
what i noticed was that the valuelist__programs functions got called for every time a record was shown in the list on one page (so for instance if i set the amount of course records to be viewed in the list to 3 , the function would get called 3 times).
this looks to be very inefficient to me. the grid is not editable so the selectboxes for the programid will not get shown anyway.
maybe this behaviour is setup for a future editable grid? if not, then the querying should behave differently for the listview (just get one programrecord for every id to be shown).
but ok, there is one thing which really puzzles me:
when i checked the record values in the debugger, the courseid never changed for every call. i would at least expect that the
$record->val('CourseID') would contain a different value for every time the delegate got called.
but it just contained the id of the first course every time the delegate function got called.
how about that?
Scott.