postSubmit missing data/ data['']= array('error','some error msg') not working

postSubmit missing data/ data['']= array('error','some error msg') not working

rw152rw152 Posts: 56Questions: 15Answers: 1
edited August 2017 in Bug reports

Hi,

I'm using the most recent release (1.6.4) of editor and the php library to go with it. I was using 1.6.3, but upgraded when I read this bug which I think may be related to what I am seeing.

in preCreate I am doing the following:

->on( 'preCreate', function ( $editor, $values) {
    if(!isset($values['somethingRequired'])){
        die(json_encode($data[] = array('error' => 'Please pick at least one something required.')));
    }
} )

This returns a structured json as expected as:

{"error":"Please pick at least one something required."}

But, the editor on the client side still behaves like data submitted correctly (the editor window closes, and therefore the user cannot see the error message). I also cannot seem to retrieve or access this error message in the following events:

postSubmit,submitComplete, submitSuccess, submitError (actually submitError is not called in this case anyway).

On the server side, the preCreate code "works," meaning the data really isn't submitted and the process is cancelled. It's a problem with the client side where I cannot catch that error and do anything with it. Instead, I've had to do a work around by creating an async ajax call in preSubmit to check if this error should happen, and, if so, return false in preSubmit to prevent the submission the server and display an error.

Thanks Allan for your help and great software!

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    Hi,

    Can you show me your client-side code please? And ideally, a link to a page showing the issue if that is possible.

    It would also be useful to be able to see a screenshot of the network tab showing the response from the server, with status code and the information it sent back.

    Thanks,
    Allan

This discussion has been closed.