How to re submit editor update form after error.

How to re submit editor update form after error.

mattwmattw 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:

Answers

  • mattwmattw Posts: 54Questions: 10Answers: 0

    oh and the obvious thing I didn't mention is that currently I cannot submit the form again

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin

    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

  • mattwmattw Posts: 54Questions: 10Answers: 0

    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?

  • mattwmattw Posts: 54Questions: 10Answers: 0

    currently all I am trying to do is click the submit button again once I enter text into the newly unhidden textbox

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    Answer ✓

    dataTables.editor.min.js:64 Uncaught TypeError: Cannot read property 'error' of undefined

    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

  • mattwmattw Posts: 54Questions: 10Answers: 0

    that could be. this is what the error response looks like

    Object {fieldErrors: Array[1], error: ""}
    error: ""
    fieldErrors: Array[1]
      0: Object
        name: "owner_just"
        status: "justification"
    
  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin
    edited June 2015 Answer ✓

    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

  • mattwmattw Posts: 54Questions: 10Answers: 0

    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.

This discussion has been closed.