Jump to content

Problems with FMView's "getInputChoices"


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

Recommended Posts

I have been debugging an issue that i have with a PHP form connected to FileMaker and have narrowed the issue to my function. I am new to PHP forms, and I think this might be a relatively easy fix, but am not sure how to approach it. Here is the issue:

When I have a field getting a value list from FMP, and the value list has a strings (with spaces) as one value, the values appear on the form, but if I check the box, save, and return to the form, the value with a space between words is unchecked. On exaiming the FMP field in the filemaker, the data is there. There seems to be an issue with the function getInputChoices echoing the string, although the value is checked in filemaker.

Here is the function:

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 am not sure if it has to do with the $eachvalue only referring to the first word of the value list line, or something else.

Suggestions?

Link to comment
Share on other sites

This is your problem.

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




 You're replacing FMP's newline value delimiter with a space and then telling php to use spaces as the delimiter for setting up the array.  Why not just use the following?




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

Edited by Guest
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

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