Announcement

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

    [Bug]:Updating form value to null with ds and field with default value (with example)

    Problem:
    When setting a null value of a property on a form with allowEmptyValue:true than not null is displayed, but the defaultValue.

    Example (can be pasted in example editor):
    Code:
    isc.DataSource.create({
    ID:"Test",
    fields:[{name:"country",defaultValue:1,allowEmptyValue:true}]
    })
    
    var form = isc.DynamicForm.create({
        dataSource:"Test",
    fields: [
            { name:"country"}
        ]
    });
    
    isc.ask("Set to null?",function(){
    form.editRecord({country:null});
    isc.say("Value is not updated to null");
    })
    Possible solution:
    in ISC_Forms.js@23923: this.setValue() is called in method _showValueAfterDraw.
    Don't know why this should be called if _value == null, but anyway a solution could be:
    this.setValue(undefined,this.allowEmtpyValue);

    #2
    allowEmptyValue only applies to certain FormItems, and isn't valid to set on a DataSourceField either, where it is not documented. This is also true of defaultValue.

    The docs for defaultValue also explicitly state that setting the field to null will cause the defaultValue to be used. So if you want the field to be able to have null value, you cannot also set a defaultValue. You could instead establish an initial value of null via dynamicForm.values.

    Comment

    Working...
    X