Hi-

Not sure where to look for the problem, but I've managed to get the libraries and module installed, create a connection, create a node and pick the layout. After adding fields (not all - it's a long form - but enough to get some relevant test data to show up) I can create a record but the only thing inserted is a date, and all other fields are empty. When I try to edit a record I see the values and then when I save, it wipes them out. I can delete a record though, no problem.

Any ideas where to look?

Thanks - really hoping to get a lot of use out of this!

Jason

Comments

jpamental’s picture

Title: Able to see fields, create form but no data inserted » Fields with spaces
Category: support » bug

OK - so I've figured out the issue but not the 'proper' fix yet. When fields in FileMaker have spaces in them, the data does not get inserted. I'm assuming that a string has to be quoted somewhere, but I've only just started to look at the module code so don't know how easy/difficult that will be.

Thanks!

Jason

tedstein’s picture

Hi. I will look into this tomorrow.

tedstein’s picture

Status: Active » Closed (cannot reproduce)

I can not replicate this at all. I am closing, but feel free to reopen with instructions on how to recreate.

Thanks.

jpamental’s picture

Status: Closed (cannot reproduce) » Active

Best description I can provide is this:

In the Filemaker Database, the field names on the layout have spaces in them - like 'First Name'

I can add that field to the Drupal node so that it appears on the 'Create' view but when I save (either 'new' or 'edit') the record will go in and the data will not (if it's new it will be blank, if it's an edit it will wipe out whatever data was in that field.

As soon as I got the client to add an underscore instead of a space, it worked like a charm.

(I don't have something to test on locally, so I couldn't try reproducing it on another database)

Hope that helps-

Jason

tedstein’s picture

Status: Active » Closed (won't fix)

Oh. Spaces and many special characters don't work with the module. I have no intention of making them work, but I should write a guide specifying what will work.

If you want to help out writing a guide, or you want to write a patch that allows spaces, please let me know.

Thanks for your feedback!

jyg’s picture

I'm going to deploy your module soon and if I run into this I will most likely supply a patch. But I'm curious, why would you have "no intention" of enabling spaces in field names? I'm not asking this to get on your case, I'm just wondering if there's some sort of FileMaker usage or standard that is driving this decision. So, if my client were to run into this problem I'llknow if the FileMaker-correct response is "change your field names" or "I'll patch the module".

Thanks! From the video, this module looks dreamy. Can't wait to save myself weeks of development time :)

jyg

tedstein’s picture

I think the correct response is 'change your field names' but a patch could be made to work.

I don't use spaces in field names, and think it is a bad practice for a variety of reasons (particularly if you access your data outside of FileMaker) but if you get a working patch going, I will integrate it.

jyg’s picture

Is it my imagination or is this working in 2.4?

tedstein’s picture

I didn't do anything to allow this to happen. Would be great if it magically started working.

jyg’s picture

Status: Closed (won't fix) » Patch (to be ported)

It was my imagination :) ... The problem was that Drupal is especially unhappy with NAME and ID attributes containing spaces and would lose the data upon submission. I ensured that NAME and ID fields never have characters incompatible with HTML4 spec, and that the the code which joins FM and the Drupal submission would be aware of this encoding.

diff -Naur filemaker/filemaker.module filemaker.patched/filemaker.module
--- filemaker/filemaker.module	2011-09-21 10:37:33.000000000 -0700
+++ filemaker.patched/filemaker.module	2011-09-21 17:33:58.555067001 -0700
@@ -982,6 +982,7 @@
         $default_value = filemaker_default_value($node, $data->default_value, $data->default_find_value, 'find');
         // Hide field if it has a dynamically generated default.
         $widget = ($default_value == $data->default_value || $data->default_create_value == 'none') ? 'textfield' : 'hidden';
+        $data->name = nameencode($data->name);
         $form['fmnode'][$data->name] = filemaker_field_for_form_array($node, $data->name, $data->label, $widget, $default_value, FALSE);
         break;
 
@@ -1005,6 +1006,14 @@
 }
 
 
+/**
+ * This utility function will encode a string to make it safe for the <INPUT NAME=""> attribute.
+ * @param string The string to encode
+ * @return string  
+ */
+function nameencode($str) {
+    return 'x'.str_replace('=','-',base64_encode($str));
+}
 
 
 /**
@@ -1032,7 +1041,7 @@
 
   // Loop through fields, setting each one.
   while ($data = db_fetch_object($fields_result)) {
-    $request->addFindCriterion($data->name, $form_state['values'][$data->name]);
+      $request->addFindCriterion($data->name, $form_state['values'][nameencode($data->name)]);    
   }
 
   // Store find request in session so we can perform a new find to recreate found set if record in it is edited or deleted.
tedstein’s picture

Thanks!

In the future, please be aware that patches are easier to apply if you upload a .patch file instead of (or in addition to) pasting in the code.

Thanks again. I will test this and it will be in 3.2, assuming everything works ok.

tedstein’s picture

Version: 6.x-1.0 » 6.x-3.x-dev
Status: Patch (to be ported) » Closed (fixed)

I added the patch.

Please note that I changed the name of your function to 'filemaker_encode_name()' because Drupal deals with namespace issues by asking module developers to start all functions with the name of their module (in this case, filemaker_[rest_of_function_name]).

The code is in 3.x-dev and will be included in the 3.2 release.

You may view it here:
http://drupalcode.org/project/filemaker.git/blobdiff/ac99f73883dbd8123ec...

tedstein’s picture

Category: bug » feature
tedstein’s picture

What is the x for?

function filemaker_encode_name($str) {
  return 'x' . str_replace('=','-',base64_encode($str));
}
tedstein’s picture

Status: Closed (fixed) » Active

I can not add this code now, as it breaks (at least) find mode. Version 6.3.2 is ready for release, with the exception of this feature.

I am reopening this as a feature request and will build this out when I have time (or, better yet, if you get some tested code, I am happy to include it). I don't use spaces in field names (or variable names, or script names, or table names, or table occurrence names, or...) so I am unlikely to prioritize it, but I do see that it will be important to the FileMaker community.

I would like to write some FileMaker coding standards that are designed to not break when integrating FileMaker with other systems. Are you interested in working with me on that?

jpamental’s picture

Ted -

Sorry to go missing on this one for a while. Just picking back up on some Filemaker integration and am about to test your new version. I think that it is important to deal with the space/character issue, but agree that the right starting point is simply documenting what will/won't work so people don't lose data.

I'll chip in as I can!

Jason

tedstein’s picture

Jason, thanks. Please check out the release candidate for 4.0. You can create buttons that call FileMaker scripts. I would love to get some feedback on it and move it to a stable release soon.

robertcharlesfox’s picture

Status: Active » Closed (won't fix)

We're not including any particular handling for fields with spaces in the Drupal 7 version, and not planning any further development of the 6 version. Marking as closed.