value lists via delegate class

A place for users and developers of the Xataface to discuss and receive support.

value lists via delegate class

Postby Dataguru » 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
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.
Dataguru
 
Posts: 27
Joined: Mon Feb 20, 2012 8:12 am

Re: value lists via delegate class

Postby shannah » Fri Feb 24, 2012 4:28 pm

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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: value lists via delegate class

Postby Dataguru » Fri Feb 24, 2012 4:42 pm

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.
Dataguru
 
Posts: 27
Joined: Mon Feb 20, 2012 8:12 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 13 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved