Jump to content

Creating an array in PHP from a Value List in Filemaker


This topic is 2814 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hello!

Another post...

Please help me out.

I am trying to create an array from a value list within Filemaker Pro (Using PHP API)

The idea is to create an array of names from a value list I have set up... Then put them into an option tag.

e.g.

$staff = array(FileMaker Value List)
^^ I know that's incorrect, but it shows what I want to do

Then with that array I want to be able to Create a HTML option list (I know how I would do that)  ---  I am just really struggling with creating the array...

Here is what I have

 

$database = "comms__web";
    $hostname = "###.###.#.#";
    $username = "web";
    $password = "################";
    
    $layoutname = "Web";
    $valueListName = "MIS";
        //CREATE FILEMAKER OBJECT

        $fm = new FileMaker($database, $hostname, $username, $password);

    //GET THE LAYOUT AS AN OBJECT.

    $layoutObject = $fm->getLayout($layoutName);
 

    //GET THE VALUE LIST

    $valueList = $layoutObject->getValueList($valueListName);

 

However it doesn't actually appear to pick up the list...

Please help me out :) 

Thanks,

Edited by Jack Wright
Link to comment
Share on other sites

You could inspect what is returned on the layout with print_r($layoutObject) and see what is in there. The value list must be associated with the field on that particular layout.

And what version of FMS are you working with? I believe that function may also be deprecated. Have you tried getValueListTwoFields instead?

Link to comment
Share on other sites

25 minutes ago, Mike Duncan said:

You could inspect what is returned on the layout with print_r($layoutObject) and see what is in there. The value list must be associated with the field on that particular layout.

And what version of FMS are you working with? I believe that function may also be deprecated. Have you tried getValueListTwoFields instead?

I am using FMS 14

Additionally 

The layout has a field on it with the valuelist assigned to it.

Nothing showed up with the print_r 
 

Link to comment
Share on other sites

Seems like you are missing the FIELD object:

//CREATE FILEMAKER OBJECT
$fm = new FileMaker($database, $hostname, $username, $password);

//GET THE LAYOUT AS AN OBJECT.
$layoutObject = $fm->getLayout($layoutName);

$fieldName = "your_field_name';

//GET THE FIELD FROM LAYOUT AS AN OBJECT
$fieldObject = $layoutObject->getField($fieldName);

//GET THE VALUE LIST ATTACHED TO THIS FIELD
$valueList = $fieldObject->getValueList();

// FOR TESTING
echo "<pre>";
print_r($valueList);
echo "</pre>";

Good luck!
Link to comment
Share on other sites

On 7/13/2016 at 4:54 PM, dwdata said:

Seems like you are missing the FIELD object:

//CREATE FILEMAKER OBJECT
$fm = new FileMaker($database, $hostname, $username, $password);

//GET THE LAYOUT AS AN OBJECT.
$layoutObject = $fm->getLayout($layoutName);

$fieldName = "your_field_name';

//GET THE FIELD FROM LAYOUT AS AN OBJECT
$fieldObject = $layoutObject->getField($fieldName);

//GET THE VALUE LIST ATTACHED TO THIS FIELD
$valueList = $fieldObject->getValueList();

// FOR TESTING
echo "<pre>";
print_r($valueList);
echo "</pre>";

Good luck!

Thank You!

Will try this out when I am next on the computer!

Link to comment
Share on other sites

This topic is 2814 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.