Announcement

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

    [V7.0RC2] DynamicForm validation resetting a date field

    Hello,

    I have a strange problem that seems to be a bug.
    Here's a simple test case.
    I have a form.
    The fields of the form are created through a DataSource.
    I have three fields :
    - "Date start" : type "date"
    - "Flat field" : type "float"
    - "Date end" : type "date"

    Here's the problem : if I empty the "Date start" or "Date end" field and click on the button (which validates the form and then shows a message), the field resets to its original value during validation.

    I have joined a diagram explaining the steps and the problem.

    Code:
    isc.setAutoDraw(true);
    var ds = isc.DataSource.create({
    		fields:[
    			{name: "0", title: "Date start", type: "date", required: false, useTextField: true, startRow: false, endRow: true,defaultValue: new Date(1228777200000)}
    			, {name: "1", title: "Flat field", required: false, startRow: true, endRow:  true,type: "float",defaultValue: 250.0,width: 150,textAlign: "right" }
    			,  {name: "2", title: "Date end", type: "date", required: false, useTextField: true, startRow: true, endRow: true,defaultValue: new Date(1287525600000)}
    		],clientOnly: true
        });
    var form = isc.DynamicForm.create({
        validateOnChange: false,
        dataSource: ds
    });
    isc.Button.create ({left: 250, click: function () {
    	if(!form.validate())
    		return;
    	alert ("Validated");
    }
    });
    I'm using version 7.0RC2PowerEdition (Note : I cannot currently upgrade to version 8)
    I tested on Firefox and Internet Explorer.

    Console Logs :
    "
    17:42:24.998:INFO:Log:initialized
    17:42:25.567:INFO:Log:isc.Page is loaded
    "

    Note : if I remove the "Flat field" from the DataSource, the problem disappears...

    Thank you
    Attached Files

    #2
    Hello,
    The issue here is that the defaultValue is a value to use instead of null for the field. Essentially setting a default makes null values get reset to the default when the form redraws.

    In SmartClient 7.x you can simply use DynamicForm.values rather than FormItem.defaultValue to specify an *initial* value without having this kind of thing happen.

    In SmartClient 8.x we've also added FormItem.value as an initialization value so you could specify formItem.value in your item configuration and have it show up as your initial value.

    Comment

    Working...
    X