Validate a row before its deletion
Validate a row before its deletion

Hi, please you help I need to add a validate before delete row, I have the following code, but nothing happend, the row still deleted,
if ($action == Editor::ACTION_DELETE) {
foreach ( $data['data'] as $pkey => $values ) {
if ( $values['estado'] === 'Invoiced') {
return 'No se puede eliminar';
}
}
}
This discussion has been closed.
Answers
A preRemove event handler could be used to add a suitable validator, or even just cancel the delete itself.
Allan
Will it be possible then to add a message to the
return false
inside the pre-events?The documentation says that errors in need of messages should be handled by the validator, but it appears the preRemove events happen first.
In my case, I need to make sure that fields are complete before the preRemove event is fired. If the field is properly formatted, I then
return false
inside my preRemove event and soft delete the object.(for the record, I can't use a die because I'm using the PDO database connection object)
If anyone else is struggling with this, this is what I did to get around it (per the documention on global editor validation)
https://editor.datatables.net/manual/php/validation
Towards the bottom