Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

FMP14 CWP Value Lists

Featured Replies

Hi,

 

For some reason I can't get value lists to work on my CWP PHP solution.

 

I have a value list "Test" with four values (one, two, three, four) on a layout called "Test" where I have a field called "Test" that is a drop down menu using the value list "Test".

When I use the following code, I get an error on my page. I have two included files one that has the $fm variable created and the filemaker.php include.

 

Here is the code:

<?php
require_once 'FileMaker.php';
require_once("secure.php");

	$layout = $fm->getLayout('Test');
	
	$values = $layout->getValueListTwoFields('Test');
?>

What I want to do is create a drop down list on my web page where the user can select from a predefined list of values. This however is seeming really difficult to do. Does anyone know why I would get an error with this?

 

Thank you,

Dan.

You need to find out what error is being thrown:


	$layout = $fm->getLayout('TestLayout');
	//   *************
	//   Error Checking Code
		if(FileMaker::isError($layout)){
		echo 'Layout Error: ' . $layout->getMessage() .'<br>';
	}
//    ********************
	
	$values = $layout->getValueListTwoFields('TestVL');
	//   *************
	//   Error Checking Code
	if(FileMaker::isError($values)){
		echo 'VL Error: ' . $values->getMessage() .'<br>';
	}
//    *******************
	$vl = '<select name="Values">';
	foreach ($values as $value) 
	{
   	$vl .='<option value="' . $value . '">' . $value . '</option>';
	}
$vl .= '</select>';

?>
<html>
<head>
<title>ValueList Test Page</title>
</head>
<body>

<center>

 <form action="VLTest.php" name="trial" method="post">
    		<?php echo $vl; ?>
			<input name="submit" type="submit" value="SUBMIT" /></form>
</td>
</body>
</html>

Note that I changed the names of the layout and value list.  Too many entities named "Test" got my head spinning.

The messages returned from the two if statements should get you started.  Post again if it doesn't get clear for you.

  • Author

You need to find out what error is being thrown:


	$layout = $fm->getLayout('TestLayout');
	//   *************
	//   Error Checking Code
		if(FileMaker::isError($layout)){
		echo 'Layout Error: ' . $layout->getMessage() .'<br>';
	}
//    ********************
	
	$values = $layout->getValueListTwoFields('TestVL');
	//   *************
	//   Error Checking Code
	if(FileMaker::isError($values)){
		echo 'VL Error: ' . $values->getMessage() .'<br>';
	}
//    *******************
	$vl = '<select name="Values">';
	foreach ($values as $value) 
	{
   	$vl .='<option value="' . $value . '">' . $value . '</option>';
	}
$vl .= '</select>';

?>
<html>
<head>
<title>ValueList Test Page</title>
</head>
<body>

<center>

 <form action="VLTest.php" name="trial" method="post">
    		<?php echo $vl; ?>
			<input name="submit" type="submit" value="SUBMIT" /></form>
</td>
</body>
</html>

Note that I changed the names of the layout and value list.  Too many entities named "Test" got my head spinning.

The messages returned from the two if statements should get you started.  Post again if it doesn't get clear for you.

No work :(

 

Using the following code (I renamed the value list to TestValueList) I got "The page cannot be displayed because an internal server error has occurred."

 

$layout = $fm->getLayout('Test');

if(FileMaker::isError($layout)) {
	echo 'Layout Error: ' . $layout->getMessage() . '<br/>';
}

$values = $layout->getValueListTwoFields('TestValueList');
if(FileMaker::isError($values)) {
	echo 'VL Error: ' . $values->getMessage() . '<br/>';

it cut off the last ending } there but yeah the filemaker error capturing doesn't even tell me anything cause it won't process the page. Using the default php install by FMS14

 

Edited by Danjmains

Try a simple php file

<?php
date_default_timezone_set("America/New_York");
ini_set('display_errors', '1');

define('FM_HOST', '<yourHost>');
$fm_file = '<yourFilename>';
$fm_user = 'username' ;
$fm_pass = 'password' ;
include ('filemaker14/FileMaker.php');// or your path to FileMaker.php
# instantiate a new FileMaker object
$fm = new FileMaker($fm_file, FM_HOST, $fm_user, $fm_pass);

$errorcheck = $fm->listLayouts();
if(FileMaker::isError($errorcheck)){
	echo $errorcheck->getCode() . ': ' . $errorcheck->getMessage();
	}
echo '<pre>';
print_r ($errorcheck);

Does the same error occur?

  • Author

Try a simple php file

<?php
date_default_timezone_set("America/New_York");
ini_set('display_errors', '1');

define('FM_HOST', '<yourHost>');
$fm_file = '<yourFilename>';
$fm_user = 'username' ;
$fm_pass = 'password' ;
include ('filemaker14/FileMaker.php');// or your path to FileMaker.php
# instantiate a new FileMaker object
$fm = new FileMaker($fm_file, FM_HOST, $fm_user, $fm_pass);

$errorcheck = $fm->listLayouts();
if(FileMaker::isError($errorcheck)){
	echo $errorcheck->getCode() . ': ' . $errorcheck->getMessage();
	}
echo '<pre>';
print_r ($errorcheck);

Does the same error occur?

No, I've already been using the PHP API to do other things like POST data into my database, etc. it just gets this error anytime I try to use a value list. As soon as I take away the code for the value list it works fine.

The code I posted above works fine for me.  Server errors have happened to me when a database has not been properly opened in FMS. They would not normally occur as a result of API calls after the database has been opened.

My sample is attached.

ValueListTest.zip

  • Author

The code I posted above works fine for me.  Server errors have happened to me when a database has not been properly opened in FMS. They would not normally occur as a result of API calls after the database has been opened.

My sample is attached.

ValueListTest.zip

Using these files I still got the same error. Uploaded to server via FMP 14 Advanced, used the php and database you attached, no luck., 

I am not familiar with checking or setting Windows file permissions (for the database), but that is where I would go next. Hopefully one of the Windows gurus will pick up the ball.

  • Author

I am not familiar with checking or setting Windows file permissions (for the database), but that is where I would go next. Hopefully one of the Windows gurus will pick up the ball.

Everything else works fine, I'm able to login, read data, write new data, get portals, perform finds, etc. It only happens when value lists are involved for some reason. It's really weird. This is using the admin account as well.

Did you change the PHP API files to the FMS14 versions when you upgraded to 14?  I had some weird problems when I didn't do that between 12 and 13. They are in a zip file in Filemaker Server/Web Publishing/ directory.

  • 4 months later...

If I am not mistaken getValueListTwoFields requires 2 parameters. The fieldname and also the RecordID.

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.