Announcement

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

    Date range validator generated for RelativeDateItem doesn't work

    SmartClient 13.1 added automatic generation of date range validators to date inputs, but this doesn't work correctly with RelativeDateItem:

    Code:
    isc.DynamicForm.create({
        ID: "dateForm",
        width: 650,
        fields: [{
            name: "pickListDate",
            title: "PickList Date",
            type: "datetime",
            editorType: "RelativeDateItem",
            validateOnChange: true,
            endDate: isc.DateUtil.getAbsoluteDate("$endOfYesterday")
        }]
    });
    Choosing any of predefined input options will result in a "Invalid value" validation error.

    Looks like previously this field contained a "isDate" validator with casting, which ensured that this field's value was always returned as a Date instance. Now it returns Date or RelativeDate, depending on the way that value was set.

    Also, looks like "required: true" no longer results in generation of a "required" validator, so en empty value always passes validation, even when it shouldn't.

    Tested in:
    • v13.1p_2025-08-03/AllModules Development Only
    • v14.1p_2025-08-01/AllModules Development Only
    Last edited by Crack; 3 Aug 2025, 10:34.

    #2
    Thanks for the report - this issue, which was a result of the dateRange validator not knowing about relative-date shortcuts, has been fixed for tomorrow's builds, dated August 5 and later.

    In the example you showed, "Yesterday" will be considered valid, as will any other shortcut that equates to a datetime earlier than the end of yesterday. RelativeDateItem.required has also been fixed.
    Last edited by Isomorphic; 4 Aug 2025, 09:51.

    Comment


      #3
      Thanks, that works correctly now.

      There's still one issue left with RelativeDateItem - in 13.1 it doesn't retain its value after DynamicForm.editNewRecord() is called.

      Test form:
      Code:
      isc.DynamicForm.create({
          ID: "testForm",
          fields: [
              {name: "f", defaultValue: "defaultValue"},
              {name: "dt", type: "datetime", editorType: "RelativeDateItem", defaultValue: "$today"}
          ]
      });
      v13.0p_2025-07-29/AllModules Development Only
      Code:
      testForm.getValues()
      Object { dt: Date Tue Aug 05 2025 00:00:00 GMT+0200 (czas środkowoeuropejski letni), f: "defaultValue" }
      
      testForm.editNewRecord()
      testForm.getValues()
      Object { f: "defaultValue", dt: Date Tue Aug 05 2025 00:00:00 GMT+0200 (czas środkowoeuropejski letni) }
      
      testForm.getValidatedValues()
      Object { f: "defaultValue", dt: Date Tue Aug 05 2025 00:00:00 GMT+0200 (czas środkowoeuropejski letni) }
      v13.1p_2025-08-05/AllModules Development Only
      Code:
      testForm.getValues()
      Object { dt: Object { _constructor: "RelativeDate", value: "$today" }, f: "defaultValue" }
      
      testForm.editNewRecord()
      testForm.getValues()
      // "dt" field is no longer in results, despite the fact that it still displays its default value
      Object { f: "defaultValue" }
      
      testForm.getValidatedValues()
      // same as getValues() - "df" is missing
      Object { f: "defaultValue" }
      It also returns Date or RelativeDate, depending on the way that value was set, but I assume that this was an intentional change, and I should update my code to accommodate it?

      Comment


        #4
        Thanks for the followup - the bug with resetting to the default has been addressed for today's builds, dated August 6 and later.

        The item may indeed produce either a Date or RelativeDate - however, please let us know if that behavior proves troublesome for some specific scenario.

        Comment

        Working...
        X