value lists via delegate class
Posted: Fri Feb 24, 2012 3:35 pm
I'm trying to limit the list of program goals to the goals of the logged in user's program
I found an example and changed it to reflect my data, however, it's not populating the value list.
in /tables/ProgObj/ProgObj.php
in the /tables/ProgObj/fields.ini I added
It's not throwing an error, but it's also not populating the value list.
I found an example and changed it to reflect my data, however, it's not populating the value list.
in /tables/ProgObj/ProgObj.php
- Code: Select all
function valuelist__ProgGoalsID(){
static $values = 0;
if ( !is_array($values) ){
$auth =& Dataface_AuthenticationTool::getInstance();
$user =& $auth->getLoggedInUser();
$sql = "SELECT ProgGoalsID, concat(GoalNo,': ', Goal) as lbl FROM ProgGoals";
if ( $user ){
$sql = " WHERE ProgramID=".$user->val('ProgramID');
$res = mysql_query($sql, df_db());
$values = array();
while ($row = mysql_fetch_row($res) ) $values[$row[0]] = $row[1];
@mysql_free_result($res);
} else {
$values = array();
}
}
return $values;
}
in the /tables/ProgObj/fields.ini I added
- Code: Select all
[ProgGoalsID]
widget:label = "Goal"
widget:question = "The high impact systems or organizational change expected to be achieved by SFY15."
widget:type = select
vocabulary = valuelist__ProgGoalsID
It's not throwing an error, but it's also not populating the value list.