Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    [Bug]: Local issue decimalSymbol "," and float input (Example included)

    * High impact issue*
    Please open showcase item with dutch locale: http://www.smartclient.com/?locale=nl#formFormulaFields

    Paste the following code in formulaFields.js:
    Code:
    isc.DynamicForm.create({
        ID:"order",
        width:500,
        fields: [
            { name:"price", title:"Price", type:"float"},
            { type:"submit", title:"Submit Order" }
        ]
    });
    Howto reproduce
    Enter value: 55,89 (comma) and press Tab. You will see the value change to 55.89 (point), now enter the field again and remove focus, it will show 5589, a really unexpected conversion of the original entered value.

    As a workaround I switched decimalSymbol and groupingSymbol to get a consistent experience;
    Code:
    isc.NumberUtil.addClassProperties({
        decimalSymbol:".",
        groupingSymbol:","
    })
    Attached Files
    Last edited by dencel; 2 Sep 2016, 12:17.

    #2
    See docs for Localized Number Formatting. To get locale-sensitive parsing and display of numbers, use the special field types "localeFloat" and "localeInt".

    The reason "55.89" is interpreted as "5589" in the Dutch locale is because the "." looks like a misplaced thousands separator. The same would happen if you entered "55,89" in en_US - the best guess, with no other context available, is that the user meant to enter "5,589" and misplaced the thousands separator.

    Your "workaround" just sets the grouping and decimal symbols back to what is used for en_US, effectively undoing the use of the "nl" locale.

    Comment


      #3
      Thanks for the link to the docs, didn't know of this feature.

      Is it correct to conclude that fieldtype "float" ignores locale formatting entirely? If so, shouldn't the input (in the example supplied above) accept the value "55.89" as a valid float value (independent of whatever locale is used)?

      Comment


        #4
        The normal "float" type becomes effectively mixed. It respects the locale settings for parsing, but the formatting is not locale sensitive (because a lot of developers do their own formatting rather than just take the default).

        Comment


          #5
          I don't think I understand entirely or maybe I am simply not happy with this behaviour. This behaviour changed from v10 to v11? The example works as expected in v10.

          V10: http://www.smartclient.com/smartclie...ValidationType
          V11: http://www.smartclient.com/?locale=n...ValidationType

          Example:
          Code:
          isc.DynamicForm.create({
              ID:"order",
              width:500,
              submit: function(){this.validate()},
              fields: [
                  { name:"price", title:"Price", type:"float"},
                  { type:"submit", title:"Submit Order" }
              ]
          });
          results see attached.

          How do I get the V10 behaviour in V11 without changing all datatypes to localeFloat? Or is this not possible?
          Attached Files

          Comment


            #6
            A change has been made for float type fields - the v10 behavior was wrong, the value wasn't being parsed at all - as of tomorrow's builds, values in a float field will be parsed as non-localized values, as intended. This means that "." is considered a decimalSymbol and "," is the groupingSymbol, or thousands-separator, and any of these will be removed prior to parsing.

            So, "55,89", with a comma, will parse to it's best-guess value, 5589 - and "55.89" will parse as a valid float with the same value.

            Comment

            Working...
            X