Announcement

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

    [bug] DynamicForm fields with NULL values are missed then `redrawOnChage: true`

    Hello,

    There is a bug in DynamicForm component.
    If DynamicForm contains a field which is a SelectItem with additional properties:
    {
    required: false,
    allowEmptyValue: true,
    emptyDisplayValue: "Select..."
    redrawOnChange: true // <- critical
    }

    and is bound to DataSource, then that field`s value is not sent to server if value is NULL.

    Scenario:
    When record has a selected value "123"
    Then If it`s changed to empty option "Select.."
    On action save that field is not sent to server ( DynamicForm.values do not contain that field)

    if "redrawOnChange" is false everything works as expected (DynamicForm.values contains a field with value NULL)

    Thought that I could set defaultValue thru "defaultValue" property, but it`s impossible to have NULL.

    Why this happens:
    FormItem is redrawn after change, so method FormItem.redrawn is called, this method calls a method
    FormItem._showValueAfterDraw(true);

    Code:
        _showValueAfterDraw : function (redrawing) {
            // If we're empty, explicitly clearValue() to re-evaluate default value
            // Otherwise just show our current value.
            if (this.isSetToDefaultValue() || (this._value == null)) this.clearValue(); // <- here clearing is triggered.
            
            else this._showValue(this._value, redrawing);
        },
    And clearValue() will call DataBoundComponent._performActionOnValue for action "clear" which removes that field from DynamicForm.values;

    As a consequence all fields which are "null" are removed from DynamicForm.values, as I said this happens only if redraw occurs.

    Could you suggest how to workaround this?

    Thanks.

    affected versions: all
    browsers: all
    tested on: SmartClient_v100p_2014-12-22_LGPL.zip

    #2
    Any fixes for this?

    Comment


      #3
      This is now fixed for 5.0 and 4.1 (in today's build), and will shortly be fixed for development builds of 5.1 as well (should be tomorrow's build).

      In SmartClient version numbers: this is now fixed for 10.0 and 9.1 (in today's build), and will shortly be fixed for development builds of 10.1 as well (should be tomorrow's build).

      Comment


        #4
        Thank You!

        Comment

        Working...
        X