10 Replies Latest reply on Sep 6, 2012 11:28 AM by JeffHorton

    PHP drop-down list data incorrect if space in value

    JimMonteath

      Summary

      PHP drop-down list data incorrect if space in value

      Product

      FileMaker Server

      Version

      11

      Operating system version

      OS X Server 10.6.6

      Description of the issue

      The code generated by the PHP Site Assistant (PHPSA) for drop-down lists returns incorrect values when a list item contains a space character. Only the characters to the left of the space are returned, the rest are dropped. The displayed data in the list is correct, but the underlying "
      Cause: The getMenu() function in the fmview.php file generated by PHPSA does not put quotes around the value retrieved from the database. HTML

      Steps to reproduce the problem

      Any drop-down list published through PHPSA should demonstrate the issue. Specific steps to reproduce are:

      1) Create a new database (e.g., "Test.fp7")
      2) Create two text fields in the default table (e.g., "State" and "Visited")
      3) Change to Layout Mode. Select a field to make a drop-down list (e.g., "Visited"). Change the Data properties to Control style = Drop-down list.
      4) Create and assign a new Value List (e.g., "Visited List") with "Use custom values" and enter some values, at least one containing a space (e.g., "Never", "Once", "Many Times").
      5) Add some records (e.g., "Alaska"/"Never", "New York"/"Many Times", "Florida"/"Once").
      6) In Manage -> Security, assign fmapp & fmphp Extended Privileges to the Full Access role in the Database (e.g., Admin user).
      7) Publish the database using FMS.
      8) Use PHPSA to generate a "Full site with Record List" website for the Layout Group (e.g., Test) and serve it through Apache.
      9) Access the website as the Full Access user. Select Find All.
      10) Click the record number for a record to browse it. Click Edit Record button.
      11) Select a drop-down value containing a space (e.g., "Many Times"). Click Save Record button.

      Expected result

      Field value in the edited record contains the drop-down list value.

      Actual result

      Field value in the edited record contains a truncated version of the drop-down list value.

      Exact text of any error message(s) that appear

      N/A

      Configuration information

      Using custom web publishing on OS X 10.6 Server's built-in Apache/PHP. Have not tested this with the FMS-shipped Apache/PHP, nor on another OS. Do not believe this to be a configuration-specific bug.

      Workaround

      Manually edit (hack) the fmview.php file in the website folder to include the required quotes.

      Locate the following line in fmview.php (around line 725):
        $options .= "";

      Enclose $encodedStoredValue in single quotes:
        $options .= "";

      This hack will be overwritten on subsequent PHPSA site generations.

        • 1. Re: PHP drop-down list data incorrect if space in value

          Jim Monteath:

          Thanks for posting and sorry about the late reply.

          I was able to reproduce this issue and have forwarded your post along with my findings to our Development and Quality Assurance (testing) departments for further investigation.

          TSBear

          FileMaker, Inc.

          • 2. Re: PHP drop-down list data incorrect if space in value
            nrobins

            I ran into the identical problem today. I am hoping to hear back from TSBear soon!

            • 3. Re: PHP drop-down list data incorrect if space in value
              nickrobins

              That last one was from my old address. I changed jobs. Still hoping to hear back from TSBear.

              BTW The same issue is found in thread http://forums.filemaker.com/posts/8278654006

              • 4. Re: PHP drop-down list data incorrect if space in value
                RustyMyers

                I'm seeing the same issue. We migrated our Filemaker 7 server to 11 and had to rebuild our php forms. It's been quite a bit of work and wasn't until the very end that we noticed this issue. It's really going to be a pain for us to work around it, but we will for now... Hoping to hear a fix for this soon.


                Thanks

                Rusty

                • 5. Re: PHP drop-down list data incorrect if space in value
                  JamesG

                  I would like to report that this is the correct solution for the problem with checkboxes as well, but is a different line number.

                  Right around line 914 it should be changed to the following:

                  if ($type == "checkbox"){
                  echo "<input type='$type' name='$fieldName" . "[]'" . " value='$encodedStoredValue' $selected>$encodedEachValue";
                  }else{
                  echo "<input type='$type' name='$fieldName' value='$encodedStoredValue' $selected>$encodedEachValue";

                  This also resolves the lack of a space character contained in the original which I found when looking at the HTML source generated.

                  This bug causes value list items with spaces to be ignored and not entered into the database in select menus and checkboxes, which is a fairly serious issue that a new user to Filemaker will never be able to resolve unless he were to figure out to remove spaces from those items.

                  It's awesome that there is a tool to generate the website code automatically, but when that coding is buggy it somewhat shatters my faith in the process. I'm now hunting down and fixing issues with fmview.php instead of working on my site that has a deadline, which isn't fun.

                  • 6. Re: PHP drop-down list data incorrect if space in value
                    brentdurland_1

                    I experienced this problem today, but had to make the edit on line 771 of the file fmviewrequest.php.

                    • 7. Re: PHP drop-down list data incorrect if space in value
                      JeffHorton

                      I am having the same issue, but i am not finding where in my code i need to edit:

                      i am only returning the 1st word from popup menu.

                       

                       

                      <tr class="field">
                                                                          <td class="field_name">
                                                                              <?php echo 'Status_Inventory' ?>
                                                                          </td>
                                                                          <td class="field_data">
                                                                              <?php $fieldName = 'Status_Inventory';?><?php $fieldValue =          $record->getField('Status_Inventory', 0) ; ?><select
                                                                              class="fieldinput" name="<?php echo getFieldFormName($fieldName, 0, $record, true, 'POPUPMENU', 'text');?>">
                                                                                  <?php $menuOptions = getMenu($layout->getValueListTwoFields('InventoryStatus', (isset($master_record)) ? $master_record->getRecordId() : $record->getRecordId()), $fieldValue, $fieldName, 'text', $submitDateOrder);
                                                                                                    if ($fieldValue == "") {
                                                                                                      $selected = "selected";
                                                                                                    } else {
                                                                                                      $selected = "";
                                                                                                    }
                                                                                                    if (($cgi->get('menuSelectedFound') == false) && ($selected == "")) {
                                                                                                      $menuOptions = "<option value='$fieldValue' selected>$fieldValue</option>".$menuOptions;
                                                                                                    }
                                                                                                    $menuOptions .= "<option value='' $selected></option>";
                                                                                                    echo $menuOptions;?>
                                                                              </select>
                                                                          </td>
                                                                      </tr>

                      • 8. Re: PHP drop-down list data incorrect if space in value
                        JimMonteath

                        Hi Jeff,

                        That looks like code from one of your page layouts. The changes suggested by me and James G need to be made in the fmview.php file where the getMenu() function is defined. However, brentdurland seemed to have success editing fmviewrequest.php to solve his problem, so maybe look in both.

                        Hope that helps.

                            Jim

                        • 9. Re: PHP drop-down list data incorrect if space in value
                          JeffHorton

                          I see now, thanks. i did edit that line in fmview.php but did not seem to fix the issue.

                          i dont have a fmviewrequest.php file in my solution.

                          changed to:

                           

                                  $options .= "<option value='$encodedStoredValue' $selected>$encodedEachValue</option>";


                          • 10. Re: PHP drop-down list data incorrect if space in value
                            JeffHorton

                            Wait! now it's miraculously working! yay!