-
1 Jan 2012 6:45 PM #1
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
- 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 .
- 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
- I expected fields that have been changed to show as dirty even if they had no original value.
- Fields with no default value show will not show as dirty when their value has been changed
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:
Test Case:Code:isDirty : function() { var me = this; return !me.disabled && typeof me.originalValue != 'undefined' && !me.isEqual(me.getValue(), me.originalValue); },
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>Try the Sencha Learning Center
-
2 Jan 2012 6:53 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,599
- Vote Rating
- 434
Thank you for the report.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
Success! Looks like we've fixed this one. According to our records the fix was applied for
EXTJSIV-4946
in
TBD.


Reply With Quote