How to re submit editor update form after error.
How to re submit editor update form after error.
mattw
Posts: 54Questions: 10Answers: 0
Hello, I am trying to figure out how I can resubmit the update form (dataTables editor) after a server error. Currently upon getting the server error I make a change to the form (unhide a hidden field) and then after entering more info I want to be able to click submit. Any help is much appreciated!
editor = new $$.fn.dataTable.Editor( {
ajax: {
// Specify URL for edit/update
// http://editor.datatables.net/examples/advanced/REST.html
edit: {
type: 'PUT',
dataType:"json",
url: '/_systemedit',
data: function ( d ) {
return JSON.stringify( d );
}
},
remove: {
type: 'DELETE',
url: '/_system.delete'
}
},
idSrc: $:hdrs.getIdSrc(),
table: "#System",
fields: [ $:hdrs.getEditData(),
{
label: "Owner change justification:",
name: "ownerJustification",
data: "",
fieldInfo: "Why are you transfering this system?",
type: "text"
}
],
}).hide( ["ownerJustification"] )
.on( 'postSubmit', function ( e, json, data, edit ) {
console.log(json);
if (json.fieldErrors[0].name){
//alert('owner justification needed');
editor.show("ownerJustification");
}
});
This question has accepted answers - jump to:
This discussion has been closed.
Answers
oh and the obvious thing I didn't mention is that currently I cannot submit the form again
Why not? Are you getting any console errors, or something else?How are you trying to submit the form a second time?
Allan
Hi allan thanks for the response. I am getting :
dataTables.editor.min.js:64 Uncaught TypeError: Cannot read property 'error' of undefined
At that point clicking on the submit button does not POST to server again or do anything client side. Do I need to "clear" the error or handle it in some way once my hidden field shows up and user wants to re submit?
currently all I am trying to do is click the submit button again once I enter text into the newly unhidden textbox
That suggests that the field name in
fieldErrors[i].name
is not a known field to the Editor configuration. Might that be the case?Allan
that could be. this is what the error response looks like
Is there a field call "owner_jsut" in your Editor form? If not, that is what is causing the problem. It is trying to set an error message for a field that doesn't exist.
Allan
ok cool thank you very much that helped clean up that error. now I just need to get the form to submit and that may be python server side.