PDA

View Full Version : msgTarget:side + DateField causes error if initial value is invalid.



cgi-bin
6 Jul 2007, 6:51 AM
Looks like the validation checks need to be deferred until the whole form is rendered?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>test</title>
<!-- Include YUI utilities and Ext: -->
<script type="text/javascript" src="ext/adapter/yui/yui-utilities.js"></script>
<script type="text/javascript" src="ext/adapter/yui/ext-yui-adapter.js"></script>
<script type="text/javascript" src="ext/ext-all-debug.js"></script>


<!-- Include Ext stylesheets here: -->
<link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css">
<script>
Ext.onReady(function() {
Ext.form.Field.prototype.msgTarget = 'side';

var F = new Ext.form.Form({
labelWidth: 150,
method: 'POST',
url:'/dev/null'
});

F.add(
new Ext.form.DateField({
name: 'date',
width: 125,
fieldLabel: 'Date',
minValue: '01/01/1900',
maxValue: new Date(),
format: 'm/d/Y',
value: '01/02/1234'
})
);

F.addButton('Save', function(){
if (!F.isValid()) {
Ext.Msg.alert('Errors', 'Please fix the errors noted.');
}
}, F);

F.render('theForm');
});
</script>
</head>
<body>
<div id="theForm" style="width: 400px; border: 1px solid black"></div>
</body>
</html>

causes error:
el has no properties
[Break on this error] if(!el.dom){
ext-all-debug.js (line 2918)

I checked a NumberField with a initial value > maxValue and it did NOT cause the same error, so it may be just the DateField code with the problem?

jack.slocum
6 Jul 2007, 8:17 AM
Can you paste a stack trace for the point of the error. Thanks.

cgi-bin
6 Jul 2007, 9:21 AM
I think this is what you want...
el has no properties
getAlignToXY(null, "tl-tr", [2, 0])ext-all-debug.js (line 2974)
alignTo(undefined, "tl-tr", [2, 0], undefined)ext-all-debug.js (line 3098)
alignErrorIcon()ext-all-debug.js (line 20464)
markInvalid("The date in this field must be after 01/01/1900")ext-all-debug.js (line 20072)
validateValue(Mon Jan 02 1234 00:00:00 GMT-0500 (Eastern Standard Time))ext-all-debug.js (line 20782)
validate()ext-all-debug.js (line 20033)
setValue("01/02/1234")ext-all-debug.js (line 20150)
setValue("01/02/1234")ext-all-debug.js (line 20342)
setValue("01/02/1234")ext-all-debug.js (line 20817)
initValue()ext-all-debug.js (line 19951)
onRender(Object dom=div#x-form-el-ext-comp-1001.x-form-element, null)ext-all-debug.js (line 19946)
onRender(Object dom=div#x-form-el-ext-comp-1001.x-form-element, null)ext-all-debug.js (line 20468)
render("x-form-el-ext-comp-1001", undefined)ext-all-debug.js (line 11106)
(no name)(Object initialConfig=Object name=date width=125)ext-all-debug.js (line 21917)
each(function(), undefined)ext-all-debug.js (line 5770)
render(Object dom=div#theForm id=theForm visibilityMode=1)ext-all-debug.js (line 21916)
(no name)()testForm.html (line 45)
fire()ext-all-debug.js (line 1426)
fireDocReady()

That is with 1.0.1a. 1.1-beta2 also has the problem:
el has no properties
getAlignToXY(null, "tl-tr", [2, 0])ext-all-debug.js (line 2918)
alignTo(undefined, "tl-tr", [2, 0], undefined)ext-all-debug.js (line 3043)
alignErrorIcon()ext-all-debug.js (line 21572)
markInvalid("The date in this field must be equal to or after 01/01/1900")ext-all-debug.js (line 21172)
validateValue(Mon Jan 02 1234 00:00:00 GMT-0500 (Eastern Standard Time))ext-all-debug.js (line 21965)
validate()ext-all-debug.js (line 21131)
setValue("01/02/1234")ext-all-debug.js (line 21250)
setValue("01/02/1234")ext-all-debug.js (line 21449)
setValue("01/02/1234")ext-all-debug.js (line 22000)
initValue()ext-all-debug.js (line 21054)
onRender(Object dom=div#x-form-el-ext-comp-1001.x-form-element, null)ext-all-debug.js (line 21049)
onRender(Object dom=div#x-form-el-ext-comp-1001.x-form-element, null)ext-all-debug.js (line 21576)
render("x-form-el-ext-comp-1001", undefined)ext-all-debug.js (line 11756)
(no name)(Object mimicing=false initialConfig=Object name=date)ext-all-debug.js (line 23960)
each(function(), undefined)ext-all-debug.js (line 6109)
render(Object dom=div#theForm id=theForm visibilityMode=1)ext-all-debug.js (line 23959)
(no name)()testForm.html (line 45)
fire()ext-all-debug.js (line 1342)
fireDocReady()