Hi,
Using Ext.data.proxy.Rest, consuming a field that comes in this format:
PHP Code:
{name: 'datejoined', type:'date', dateFormat:'Y-m-d H:i:s'}
displays in grid correctly.
Edit the grid record using a form with the date field of:
PHP Code:
{
xtype: 'datefield',
name: 'datejoined',
fieldLabel: 'Date joined',
format: 'd/m/Y',
altFormat: 'Y-m-d H:i:s' // Just tried this on the off chance, but it didnt help the problem
},
The date displays correctly.
BUT... if I save the form which gets me to here in my controller:
PHP Code:
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values);
The date ends up as an empty string in the record:
record.set(values) --> field.convert(value, me); --> Ext.Date.parse(v, df);
The reason is that Ext.Date.parse fails because the string from the form field value (v) is in the format 'd/m/Y' while the date format (df) uses the model field's dateFormatof 'Y-m-d H:i:s'!
It seems strange that I cant display a form field date in any format I choose and have the record.set() method use the form field's format to convert to a date object!
My work around is as follows:
PHP Code:
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
var fld = form.getForm().findField('datejoined');
var fldFormat = fld.format;
values.datejoined = Ext.Date.parse(values.datejoined, fldFormat);
record.set(values);
That works because I am taking care of the conversion myself before record.set() gets it. (The date is then correctly converted to the ''Y-m-d H:i:s' by the writer before being sent to the server).
So, am I configuring something incorrectly, or is this a bug?
Thanks,
Murray