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.

Value list error in editing related records via php

Featured Replies

I have a php solution that has a layout in which the user can edit a list of records via a relationship. (FMPS 9) In other words, I have a campus (1 record) with a portal to teachers (many records)shown as a big list with just a few fields that are editable. I created this layout as a work-around having to edit each record individually.

Everything works, the director at the campus can login, retrieve the campus list of teachers, and edit the fields on the list, no problem. The issue I have is that when I add a pop-up list, radio buttons or any type of value list, there is an error on the edit page.

I have double-checked that the layout in FMP does have the value list. Here is my web page code for one of the fields:

Returning / hired:<?php getInputChoices("radio", $layout->getValueList('YesNo', $record->getRecordId()), $record->getField('FacultyFromSites::Hired', 0) , getFieldFormName('FacultyFromSites::Hired', 0, $record));?>

and the web page error I see is this:

Warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/AimHigh/Faculty2010 copy/fmview.php on line 552

and in my fmview file, line 552 is in the getInputChoices function, and is the first "foreach" line shown below:

function getInputChoices($type, $valuelist, $fieldvalue, $fieldName) {

$selected = "";

$fieldValueArray = explode(" ", str_replace("n"," ", $fieldvalue));

foreach ($valuelist as $eachvalue) {

if (in_array(trim($eachvalue), $fieldValueArray)){

$selected = " checked";

}else{

$selected = "";

}

if ($type == "checkbox"){

echo "$eachvalue";

}else{

echo "$eachvalue";

}

}

}

I have removed the value lists for now, but would love to be able to put them in, to save on data cleanup for these forms.

Any advice would be appreciated! Thanks!

  • 3 weeks later...

What you have is not really an error in the classic sense. It's just a "warning", which in PHP parlance basically means I know what to do, but I didn't get what I expected so you might not either.

In this case the foreach statement is expecting an array as the first variable and it isn't getting one. My first guess is that the value-list in question doesn't have any values and what ever code set it made it null instead of an empty array.

If the value-list does in fact have values you should look at the code that calls getInputChoices() an see where the second passed variable is getting set.

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.