Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

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...
Posted

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.

This topic is 5282 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.