AnsweredAssumed Answered

How To build PHP Value List with Variable Name

Question asked by SethRedlus on Nov 25, 2016
Latest reply on Nov 26, 2016 by SethRedlus

Hello All.

I'm pretty stumped on this, and hoping some of you might have a few ideas. I am attempting to build an interface where I specify a value list name in the database, and when the I build an input page via PHP, it uses the valuelist name that I identified in the database to pull the correct valuelist. What I can't figure out is how to dynamically specify the valuelist name in the getValueListTwoFields function. Here's an example:

 

$layout = $fm->getLayout('mylayout'); \\Identify The Layout
$values = $layout->getValueListTwoFields('ValueList'); \\ This is the line where I need to dynamically specify the value list.

 

I have tried several things to populate the value list name using data from a field that is found in a search earlier in the script. My hope would be that I could pull the data into a variable, and then populate the variable into the function - but that doesn't work. That would look like this:

$result->getField('ValueListName'); \\The field that stores the name of the value list
$values = $layout->getValueListTwoFields($result); \\Trying to insert the value list via variable - DOESNT WORK!

 

I have also tried building it as a string... no dice there either.

$values = "$layout->getValueListTwoFields('" . $result->getField('ValueListName') . "')";

 

I have a feeling that there is a PHP way to deal with this - I've looked at classes, global variables and custom functions and haven't been able to make heads or tails of it. Anyone have any pointers perhaps?

Thanks in advance!

Outcomes