Redirect error message from Editors PHP script to a different DIV

Redirect error message from Editors PHP script to a different DIV

richardvkrichardvk Posts: 13Questions: 7Answers: 0

Hi,

I am using Editor to do the usual Create, Edit and Delete of entries on a table.

However, in the PHP script (server side) I am running a custom check before delete (before the ->process() is called) to ensure the row SHOULD in fact be deleted. (See here )

If I determine that the delete should NOT go ahead, i create a custom json return object with an 'error' message (as you would get on any other database error).

I am also using datatables
editor.title('..')..buttons('..').message('..').remove(this)
type method on the client side to generate the confirmation modal ("Are you sure you want to delete...?")

When i return my custom error message, the message gets added in the modals footer, as per browser inspector:

<div data-dte-e="form_error" class="DTE_Form_Error" style="opacity: 1;">My custom error message here.</div>

My question is: is there a client side event handler that i can use to close the modal and return the error message to a different div on the page (which is my standard 'error message area' on my page)

I have tried:
editor.on( 'submitError', function(){...} )
but it does not seen to be triggered - maybe i need to pass something else back in my custom crafted json to get this to trigger??

Thanks!
Richard

Answers

  • allanallan Posts: 63,522Questions: 1Answers: 10,473 Site admin

    Try listening for the postSubmit event - there you will be able to check for any information in the json data (it is passed in as a parameter to the event handler's function) and display it as you require.

    Regards,
    Allan

This discussion has been closed.