PDA

View Full Version : Individual Field before submit changing



SUPER_X
9 Oct 2009, 9:24 AM
Hello, I have an application, within it I have many different date fields in different forms. Since I have custom configuration I use on every date field I've created a subclass of Ext.form.DateField. This configuration includes a different format from the default, wich is necessary for the application. Even though, I'd still like to send in the form the date in sql format 'Y-m-d'.

I have achieved this manually when I'm using EditorGrid by calling Ext.util.Format.date(v.fechaField,'Y-m-d');. What I'd like to do is to add the behaviour to this subclass so each time a form is submitted this fields gets transformed to Y-m-d format before it's sent to the server.

I can't even find a way to do this manually on each form without bypassing validation, if I use setRawValue it displays an awful NaN/NaN/NaN on the field and it doesn't even work. I don't know if there's an event fired before submitting but after validation is done in the form.
Maybe if I find that event I can make a subclass of FormPanel wich fires an event on each field at that time? I think this probably exist, I just can't find it.

Thanks for reading.

zhegwood
9 Oct 2009, 11:02 AM
I wouldn't use setRawValue w/ a date field & custom renderer. Try creating a javascript Date object and set the day, month, year, etc and pass that object into the date field's setValue() function.

SUPER_X
9 Oct 2009, 11:12 AM
If you set a value it'll just send the data in the DateField format.

Other solution would be to just use a custom ajax call instead of using the .submit(), that way I could just send whatever I want. I'd still like to save me some lines by making this behaviour normal. I'm thinking maybe letting the format be Y-m-d and having something like 'displayDate' wich would be what's rendered in my other format. But that doesn't exist.