Announcement

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

    Bug? Masked fields with cleared values return 'null' string value

    Version: SmartClient 8 nightly, 2011-05-06

    If a masked field has a value in it and you clear the value, when the form is submitted a string containing the word "null" is sent, rather than a javascript null or empty string. For example, here is the JSON string returned from the fetch:
    Code:
    {"address":{"state":"FL","street1":"","street2":"","city":"","zip":""},"name":"Florida","phone":"4055551212","officeId":39,"phone2":null}
    You'll notice that the field "phone" has a value of 4055551212. Field "phone2" has a value of null. This null is not a string.

    Now, we clear the form's field for phone and watch the json that is submitted back to the server during the update call:

    Code:
    {"address":{"state":"FL","street1":"","street2":"","city":"","zip":""},"name":"Florida","phone":"null","officeId":39,"phone2":null}
    We can see that the value for phone has been replaced by a string whose value is the word "null". Expected behavior is that the value would be set to either an empty string or a Javascript null value. We can also see that this is a direct result of editing the field because the phone2 value, which was not touched when using the form, is still a true null.

    If a mask is not applied to a form field, this behavior doesn't happen. Blanking out a regular text field on a form results in an empty string being sent to the server.



    I've tested this in Chrome, Firefox 3.6 and 4.0, and Opera 11.


    Here is a test case

    Code:
    isc.RestDataSource.create({
       ID: 'datasource',
       dataFormat: 'json',
       dataURL: 'directory',
       recordXPath: '/',
       titleField: 'name',
       fields: [
               { name: 'officeId', primaryKey:true, required:true, type:'integer'},//, detail:true},
              { name: 'name' },
              { name: 'street1', valueXPath: 'address/street1'},
              { name: 'street2', valueXPath: 'address/street2'},
              { name: 'city', valueXPath: 'address/city'},
              { name: 'state', valueXPath: 'address/state'},
              { name: 'zip', valueXPath: 'address/zip'},
              { name: 'phone'},
              { name: 'phone2'}
           ]
    });
    
    
    isc.DynamicForm.create({
       ID: 'testform',
       dataSource: datasource,
       numCols: 6,
       width: 700,
       height: 200,
       autoDraw: true,
       saveOnEnter: true,
       fields: [
           { name: 'name', colSpan: 6},
           { name: 'street1', colSpan: 1},
           { name: 'street2', title: 'Street 2', colSpan: 2},
           { name: 'city', colSpan: 1},
           { name: 'state', colSpan: 1, editorType: 'StateSelector'},
           { name: 'zip', colSpan: 1, mask: '#####-####'},
           { name: 'phone', colSpan: 1, title: 'Phone', mask: '###-###-####' },
           { name: 'phone2', colSpan: 2, title: 'Alt Phone', mask: '###-###-####' }
       ]
    });
    
    testform.fetchData({'officeId':1});


    The same thing happens if the original value of the field is null. If you enter the masked text field, put in a value, remove focus by going to another field, then return the the masked field and clear the value that you just entered, a string with the word "null" will be submitted.

    #2
    Considering the upcoming 8.1, I'm bumping this so it doesn't get overlooked

    Comment


      #3
      Bumped, in the name of science

      Comment


        #4
        I'm unable to reproduce this. Can you narrow it down to a form without a data source and see the "null" string in the form values?

        Comment

        Working...
        X