Success! Looks like we've fixed this one. According to our records the fix was applied for EXTJS-4946 in a recent build.
  1. #1
    Sencha User bclinton's Avatar
    Join Date
    Nov 2007
    Posts
    286
    Vote Rating
    11
    bclinton will become famous soon enough bclinton will become famous soon enough

      0  

    Default 4.1: Form/Field isDirty() shows false if field has no original value

    4.1: Form/Field isDirty() shows false if field has no original value



    Ext version tested:
    • Ext 4.0.7 and 4.1-PR1, 4.1.0-beta-1
    Description:
    • The isDirty() function in Ext.form.field.Field has been changed in the 4.1 preview release and now reports that fields without an original value are not dirty when they have been changed .
    Steps to reproduce the problem:
    • Make a form that contains fields without a default value, change one or more of those fields, test isDirty(), fields will not show as dirty
    The result that was expected:
    • I expected fields that have been changed to show as dirty even if they had no original value.
    The result that occurs instead:
    • Fields with no default value show will not show as dirty when their value has been changed
    I'm not sure if this is a bug or if it is working as designed. The isDirty() function in Ext.form.field.Field has been changed in the 4.1 preview and beta releases.

    This is the function in 4.07:
    Code:
        isDirty : function() {
            var me = this;
            return !me.disabled && !me.isEqual(me.getValue(), me.originalValue);
        }
    ,
    In the 4.1 PR1 and 4.1.0-beta-1, the function disregards changes in fields with an undefined originalValue:
    Code:
        isDirty : function() {
            var me = this;
            return !me.disabled && typeof me.originalValue != 'undefined' && !me.isEqual(me.getValue(), me.originalValue);
        },
    Test Case:
    Here is a working test case for a simple form. Type something into the textfield and then click the button. In 4.0.7, the field/form isDirty function will report true. In 4.1-PR1 and 4.1.0-beta-1, the field/form isDirty function will report false because the originalValue is undefined.

    Code:
    <html>
    <head>
        <title>Form dirty test</title>
    </head>
    <body>
    <div id="form-div"</div>
    <div id="script-div">
    
    
        <!-- ExtJS style sheets and library -->
        <link rel="stylesheet" type="text/css" href="lib/ext/resources/css/ext-all.css">
        <script type="text/javascript" src="lib/ext/ext-all-debug.js"></script>
    
    
        <script type="text/javascript">
        Ext.onReady(function() {
    
    
            Ext.create('Ext.form.Panel',{
                renderTo : 'form-div',
                height   : 160,
                width    : 320,
                title    : 'Test Form',
                items   : [
                    {
                        // textfield has no initial value
                        name        : 'test',
                        fieldLabel  : 'type something here',
                        labelWidth  : 120,
                        xtype       : 'textfield'
                    }
                ],
                buttons : [
                {
                    text    : 'test dirty',
                    listeners: {
                        click: function(button)
                        {
                            var form    = button.up('form'),
                                field   = form.down('textfield[name=test]');
    
    
                            Ext.Msg.alert('Info',
                                'field original value: '+field.originalValue+'<br />'+
                                'field current value: '+field.getValue()+'<br />'+
                                'form isDirty():'+form.getForm().isDirty()+'<br />'
                            );
                        }
                    }
                }]
            });
        });
        </script>
    </div>
    </body>
    </html>

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    898
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thank you for the report.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1