8 Replies Latest reply on Mar 2, 2017 4:19 PM by charmcello

    FMP PHP API: dropdowns and radio buttons missing on web form

    charmcello

      I am tasked with troubleshooting a web registration form that queries a Filemaker Pro v12 database via a Filemaker PHP API.

       

      The web form had been running well for a couple of months after major revision, when all of a sudden:

      1. All dropdowns are empty
      2. All radio buttons are missing
      3. These symptoms appear to be browser-independent.

       

      The appearance of these symptoms is mysterious:

      1. Nobody has modified the PHP code for the web form - I've done a compare with a backup done at the time when the web form was not broken and it is identical to what is currently on the server.
      2. The Filemaker Pro layout that the web form is querying is just fine - all the value lists for the dropdowns and radio buttons are present.

       

      I've created a stripped-down version of the web form: https://campmeetings.cccsda.org/test_form.php and I've also attached the php source code file.

       

      The date and record fields are populating correctly. Notice the empty dropdown list after "Church I attend."

       

      Could this be caused by an incompatibility between the FMP PHP API and PHP libraries on the server? Perhaps due to a PHP update on the server? Any ideas how to troubleshoot this?

        • 1. Re: FMP PHP API: dropdowns and radio buttons missing on web form
          mikebeargie

          The PHP in lines 1-18 of your file don't appear to follow standard code from the PHP API.

           

          For example, AFAIK there is no function called fmsTrapError() in the API.

           

          Upon further investigation, it appears this form was created with FMStudio. As far as I know that was using fx.php and not the standard filemaker API. FMStudio is also DOA, with no known updates since version 12.

           

          What broke it? unknown... probably you are missing references to some files that FMStudio generated or was using. Or something in there is no longer compatible with an update.

           

          How to fix it? I would suggest rewriting it using the current API standards and files.

          https://fmhelp.filemaker.com/docs/15/en/fms15_cwp_guide.pdf

          1 of 1 people found this helpful
          • 2. Re: FMP PHP API: dropdowns and radio buttons missing on web form
            charmcello

            Oh, sure enough! It does indeed appear that the previous developer used FMStudio.

             

            Yes, I agree that recoding might be in order here.

             

            Where can I find information about API versions and what FMP versions they're compatible with? Our system is currently using v12 but we may soon be upgrading to v15.

            • 3. Re: FMP PHP API: dropdowns and radio buttons missing on web form
              mikebeargie

              You should be using the PHP API files that come inside of the installer folder with your version of FileMaker server.

               

              Usually they are installed to program files (or library on mac) /FileMaker Server/Web Publishing/FM_API_for_PHP_standalone.zip on the server.

               

              You are looking for a file called “FileMaker.php”, and a folder called “FileMaker”

               

              Copy the file and folder to your website directory.

               

              Add:

              Include(‘FileMaker.php’);

              To your PHP code, and you’re ready to start using the PHP API.

               

              A good intro article, maybe a little old but still useful, is:

              sixfriedrice.com/wp/up-to-speed-with-the-filemaker-php-api/

               

              it covers establishing a connection to a database and reading out basic found sets.

              1 of 1 people found this helpful
              • 4. Re: FMP PHP API: dropdowns and radio buttons missing on web form
                charmcello

                Thank you so much, you've been ever so helpful!!

                • 5. Re: FMP PHP API: dropdowns and radio buttons missing on web form
                  charmcello

                  I have another question:

                   

                  The FMStudio code has a function "fmsLiveInputField()" that updates between the web form and the database instantaneously. (I assume 'fms' stands for FMStudio.) This is the function that isn't working correctly in the current application.

                   

                  Is there some analogous dynamic field functionality in the regular PHP API (the non-FMStudio version)?

                   

                  I've searched, but haven't found anything. The following forum post indicates that there is no such dynamic field functionality outside of FMStudio and that it needs to be implemented with javascript:

                   

                  Dynamic Field using CWP - API - Custom Web Publishing - FMForums.com

                   

                  Any tips on the best way to implement dynamic field functionality would be very appreciated!

                   

                  mikebeargie

                  • 6. Re: FMP PHP API: dropdowns and radio buttons missing on web form
                    mikebeargie

                    The PHP/XML API is transactional, so that is correct, nothing updates in realtime like the behavior you see in filemaker itself. Rather, data is "posted" to a form that saves your changes or additions (or deletions) at the time of request.

                     

                    Javascript (specifically AJAX, which is a combination of javascript and other things) essentially breaks up those "post" actions into smaller on-demand segments, rather than as a single bundled request at post time.

                     

                    I actually prefer the single "save" button method and posting of a completed form. I use javascript for realtime form validation, but NOT for read/write database actions in realtime. Doing so actually slows your web page down as you wait for request/responses from ajax. This can result in odd behavior. So I have an "edit record" button that pre-loads a form with the existing record data, and a "save" button that posts and saves the form data. This way it's clear to the user when they are editing data or not.

                     

                    If you do want to pursue it though, I would go through this intro so you understand the concepts:

                    AJAX Introduction

                     

                    From there, you will most likely need to switch to the XML API instead of PHP to make it easier to interface with Filemaker. Then I would start with a simple one-field form page and get the request/response updating. Once that's working you can implement it in your form wherever needed with copying and pasting.

                     

                    Remember FMStudio used FX.php, and not the filemaker PHP/XML API, so it has slightly different capabilities and code. You'll need to rebuild that functionality if you want to use it with the current API.

                    • 7. Re: FMP PHP API: dropdowns and radio buttons missing on web form
                      beverly

                      In addition to MBs advice, I will add:

                      If you are looking for something like conditional (cascading) value lists with CWP and your lists are not excessively long, so can store the values in JS arrays. Call them ONCE to store as static text and use as includes for the JS to process. This can be very fast, not need the AJAX and not take trips to & from DB.

                      Many dependencies, but may be an option for even single (non-cascading) value lists.

                       

                      Sent from miPhone

                      • 8. Re: FMP PHP API: dropdowns and radio buttons missing on web form
                        charmcello

                        Thank you so much, beverly and mikebeargie for your very helpful advice and tips. I've been on the road this week so I haven't had time to try any coding yet, but I think I know what I need to do now. Thanks, again, so much for helping me out!! You have no idea how much I appreciate it.