Change data submitted to the server
Change data submitted to the server
lucianonapoli
Posts: 1Questions: 0Answers: 0
Hello, I'm trying to have the possibility to change the submitted data to the server but without success.
Have tried this but the form is updated and the submit sends the old data to the server.
editor.on( 'preSubmit', function ( e, o, action ) {
if ( action !== 'remove' ) {
var salary = editor.field( 'users.salary' );
if (!salary.val()) {
salary.error('Value not valid');
}
var salaryFloat = parseFloat( salary.val() );
if ( salaryFloat < 100 ) salaryFloat = 150;
editor.set( 'users.salary', salaryFloat );
// also tried salary.set(salaryFloat);
if ( this.inError() ) {
return false;
}
}
} );
Maybe I understand that have to use
editor.submit(successCallback, errorCallback, formatdata, hide)
but don't understand how. Please can you provide me an axample?
Thanks
This discussion has been closed.
Replies
You can't use the Editor API methods to set a new value at that point (in
preSubmit
) as the data has already been gathered from the form. You need to modify the data in theo
object (second parameter passed in) if you want to change the data that is submitted. It is that object that will be sent to the server.Allan