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

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

Recommended Posts

  • Newbies
Posted

Ok I searched the forums here and haven't found quite the solution I'm looking for. I'm relatively new at PHP, but I've been learning quickly as I go in creating this Filemaker API site.

Basically the problem i am running into is updating values in a checkbox set on one of my filemaker layouts.

When I do a find command and retrieve the data from filemaker, it gives me the checkbox values in what looks like a space delimited list, e.g. '214.0 214.29 215.9'

Upon further investigation, doing a urlencode($returnvalue) i get this:

'214.0%0A214.29%0A215.9'

If I try to add another %0A and the next value to the end of the url encoded string, then send it back to filemaker with a urldecode, I dont get any checkboxes checked back in filemaker.

How can I add a value to the list and send it back to filemaker?

Posted

You could perhaps avoid the problem by:

1) creating a new text field in FileMaker called "updated_checkbox_values"

2) send your value back there without any urldecode

3) set your actual checkbox set to an auto-enter calculation with the expression

substitute( "updated_checkbox_values" ; "%0A" ; "¶" )

[the thing between the last pair of quotes may not come out correctly here, if not it is the paragraph symbol, looks like a backwards-P, there is a button for it in the define calculation window... someone told me the other day what the correct technical name of it was, but I've forgotten]

4) set the auto-enter calculation to 'replace existing values'

Because the auto-enter calculation replaces existing values, it should update itself every time the PHP file posts back a value to the "updated_checkbox_values" field.

Keep your PHP "find" on the original field (the one that is now an auto-enter).

You may need to experiment with variations of the above as I am not 100% familiar with the encodings involved with checkboxes in PHP.

I've subscribed to this thread though so come back if you've any problems.

Yours

James

  • Newbies
Posted

Thanks for the reply! The paragraph symbol is what I was missing.. The checkbox field is actually contained in a related table, so the auto-calculated field wasn't working right I think.. What I ended up doing as a solution was the following (for anybody else with this issue):

1. In PHP, retrieve the checkbox field, which for example returns 102.1 102.2

2. In PHP, do a urlencode on the string to get 102.1%0A1.2.2

3. Append the new value on the end with another %0A string (102.1%0A102.2%0A102.3)

4. Send new string to filemaker in a temp field (temp_code_field)

5. In filemaker, create a script with SetField(substitute(checkbox_set_field, "%0A", "¶"))

6. Call the script on Record Commit in the Layout parameters.

Works like a charm.

  • 1 month later...
  • Newbies
Posted

The %0A is a line feed, chr(10) in PHP, but FM, on the Mac anyway, wants carriage returns. I solved this problem by first replacing the line feeds with carriage returns like this:

str_replace(chr(10), chr(13), $chboxVals);

Then, to add a new value to an existing checkbox set, I did this:

$chboxVals = 'new value' . chr(13) . $chboxVals;

Seems to work fine.

Posted

Sounds like your problem is solved, but if anyone else would like to read up on checkboxes + php + filemaker, you might want to check out my article on the topic in Advisor:

http://my.advisor.com/doc/19601

  • 5 months later...
Posted

Jonathon, I saw your fix in your article at Advisor and it seems to make sense, but in my situation I need to send blank check-box values for records in a portal.

Just not sure where I put the item ( ) when the records are in the portal.

Love the technique otherwise, it's been a huge help!

Thanks,

Mike

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