[Users] GeoExt.plugins.AttributeForm Date Handling
Adam Ratcliffe
adam at prema.co.nz
Fri Aug 6 02:34:54 CEST 2010
Hi,
I've needed to make a few changes to the handling of date attributes
in the AttributeForm class in order to exchange GML feature
representations with GeoServer. The way I've done it is not
particularly nice so maybe somebody else has a better way?
- Firstly I overrode the Ext.form.DateField.getValue() method to
return a datetime string in ISO 8601 format. I did this because the
OpenLayers GML format class relies upon automatic type conversion to
convert all feature attributes to strings.
- To read the datetime string back into the DateField I added the ISO
format to the altFormats list.
My changes are shown below:
if(type.match(this.regExes["date"])) {
this.formPanel.add({
xtype: "datefield",
fieldLabel: name,
name: name,
format: 'd-m-Y',
altFormats:
'm/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d|Y-m-d\\TH:i:sP',
getValue: function() {
var v =
this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) ||
'';
return (v instanceof Date) ?
v.format('Y-m-d\\TH:i:sP') : v;
}
});
Cheers
Adam
More information about the Users
mailing list