PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Field Values cut off at 200 chars in locales different than EN_US

  1. sboisvert@bryxal.ca
    Member

    I had a rought time figuring it out but finnaly I found the bug,
    on line 1390 of forms_model.php
    "WHERE lead_id=%d AND field_number = %d ", $lead_id, $field_number - 0.001, $field_number + 0.001);"
    That fails when the wordpress Locale is something like French, the commas get interpreted differently somewhere in the prepare statement and the query fails and you get stuck with the short version of the string.

    changing the line to this:
    "WHERE lead_id=%d AND field_number = %d ", $lead_id, $field_number);"
    will fix the issue.
    I saw other places in the code where Between is used with the same logic of using floats instead of Int in the SQL query. I'm not entirely sure why it was done, I'm sure there was a logical reason at some point in time (or debugging and never got put back).
    Either way, I hope it can be of use to others.

    -S

    Posted 13 years ago on Monday September 27, 2010 | Permalink
  2. Does it fail for every entry or just for ones with commas in it?
    The field_number needs to be a float because multi-input fields such as name and address store each input value (first name, last name, etc..) as a float. So your solution might work for basic fields but it won't work on all scenarios. If the BETWEEN syntax is creating issues for the french locale, I can look into fixing the problem. Can you give me a detailed description on how to replicate the issue?

    Posted 13 years ago on Monday September 27, 2010 | Permalink
  3. sboisvert@bryxal.ca
    Member

    Thank you Alex,
    Every entry gets cut off at 200 char.
    Its a standard Paragraph text.
    We are using the WPML plugin to manage the multiple locales on our blog, that will make it easier for you to test with the French locale.

    you can view both the french and english versions of the forms here:
    http://www.liberal.ca/fr/contactez-nous/
    http://www.liberal.ca/contact/

    Thank you,

    Posted 13 years ago on Monday September 27, 2010 | Permalink
  4. How is this implemented? Are you using the same form and using WPML to translate them some how or are those 2 separate forms?

    Posted 13 years ago on Monday September 27, 2010 | Permalink
  5. sboisvert@bryxal.ca
    Member

    Hi Carl, these are two separate forms.

    Just to note this problem is still in the most recent version of Gravity forms. And it still cuts off after 200 characters. (From my understanding this is that the long field doesn't get recognized and therefore only the shorter 200 char version field gets used)

    It is now in line 2089:
    get_field_value_long()
    from:
    $sql = $wpdb->prepare(" SELECT l.value FROM $detail_table_name d
    INNER JOIN $long_table_name l ON l.lead_detail_id = d.id
    WHERE lead_id=%d AND field_number BETWEEN %f AND %f", $lead_id, $field_number - 0.001, $field_number + 0.001);
    to:
    $sql = $wpdb->prepare(" SELECT l.value FROM $detail_table_name d
    INNER JOIN $long_table_name l ON l.lead_detail_id = d.id
    WHERE lead_id=%d AND field_number = %d ", $lead_id, $field_number);

    Thanks.

    (Again, I saw that this is not the right way to fix it, but just re-showing what I did to fix it, I understand it won't work for multi-fields and am keen on helping you fix it as we are using Gravity forms more and more)

    Posted 12 years ago on Friday December 16, 2011 | Permalink
  6. sboisvert@bryxal.ca
    Member

    Now this (standard build, without my changes, latest version) has the repercussions that having wordpress load up with the French locale (fr_ca or fr_fr in French where doubles are stored as 14,1 internally makes gravity forms not recognize any address field or other field that has the 14.1 field numbering.
    Those fields are not processed by:
    if($lead != null && $value == rgget($input_id, $lead)) line 1883 of forms_model.php in the function save_input()

    Posted 12 years ago on Thursday March 29, 2012 | Permalink
  7. sboisvert@bryxal.ca
    Member

    Note for the original bug, I've fixed it this way to keep the double val and not have it change the values to localized floats for the SQL statement

    in get_field_value_long() change to:

    $sql = $wpdb->prepare(" SELECT l.value FROM $detail_table_name d
    INNER JOIN $long_table_name l ON l.lead_detail_id = d.id
    WHERE lead_id=%d AND field_number BETWEEN %s AND %s", $lead_id, doubleval($field_number - 0.001),doubleval($field_number + 0.001));

    Posted 12 years ago on Monday April 2, 2012 | Permalink