Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82213

->data() with custom validation and throw message...?

$
0
0

Hello,

i use datatables editor with ->data()...

  $data = Editor::inst( $db, 'MY_TABLE', 'Id' )
  ...shorted...
  ->process( $_POST )
  ->data();

  // Additional example data...
  $addtionalData['foo'] = "bar";

  $result = [
    'data' => $data['data'],
    'additional' => $addtionalData
  ];

  echo json_encode($result, JSON_PRETTY_PRINT );

My Problem is now, send error messages via throw, back to the editor. As Example:

  ->on('preRemove', function($editor, $id, $values) {
    if ( $id == 1 ) {
      throw new Exception('<span>Example error (this item cannot removed!)</span>');
    };
  })

The throw will not execute. After click the 'remove' button on the editor modal frontend, the editor close without any messages and remove the item.
If i remove the ->data(); and change to ->json(); it works well...


Viewing all articles
Browse latest Browse all 82213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>