How to access 'data' on presubmit
How to access 'data' on presubmit

I'm working on an editor form. I'm using an ajax call to make some decisions, and some actions based on the fields at work. This part works so far.
But when I send data back to the editor form for the submit, I can't change a field using editor.set(field, value) like I do during other events. I use alerts and can see the data is coming back correctly and displays OK.
editor.on( 'preSubmit', function (e, data, action) {
var res = processShipment(editor, id_cust, id_part, ship_quan);
alert(res[0].label); // these show correct data
alert(res[0].value);
editor.set('some_field1', res[0].label); // these dont update the fields
editor.set('some_field2', res[0].value);
// other stuff
}
I wonder now how to access the 'data' object. I can do the alert(JSON.stringify(data)) and see the data object. How would I set a particular data field to the content I receive in res?
Thanks for any help.
This question has an accepted answers - jump to answer
Answers
When
preSubmit
executes the values have already been read from the fields - so any value you set will no effect the submitted data. Rather you would need to modify the submitted data (the second parameter passed into the event). For example:data.data.some_field1 = res[0].label;
.Allan