Page 1 of 1

value lists via delegate class

PostPosted: Fri Feb 24, 2012 3:35 pm
by Dataguru
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
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.

Re: value lists via delegate class

PostPosted: Fri Feb 24, 2012 4:28 pm
by shannah
Code: Select all
vocabulary = valuelist__ProgGoalsID

should be
Code: Select all
vocabulary = ProgGoalsID


When you define a valuelist with the valuelist__valuelistname() method, you are defining a valuelist named "valuelistname" not "valuelist__valuelistname".

_Steve

Re: value lists via delegate class

PostPosted: Fri Feb 24, 2012 4:42 pm
by Dataguru
Thanks.

It's still not working.

What's the best way to troubleshoot the php code?
I tried inserting echo statements, but none would display.