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

How to hide generic datatable editor error

$
0
0

Hello,

I would like to hide generic datatable editor error like "System Error" or "SQL Error".
I begin to do below but now all my custom error like "Nothing data." are replaced by "An error occured. Contact IT support."

It's possible to keep custom error and handle generic datatable error only to "An error occured. Contact IT support."

Thanks You

    $editor = Editor::inst( $db, 'PERSONEL', 'PERSONELTABLE' )
        ->fields(
            Field::inst( 'USERID' )->validator( 'Validate::notEmpty' )
        )
        ->validator(function ($editor, $action, $data){
            if ($action === Editor::ACTION_EDIT || $action === Editor::ACTION_DELETE){

                if(count($data["data"]) === Null){
                    return "Nothing data.";
                }

                if(count($data["data"]) > 0){
                    return "Can't modify multiple row.";
                }
            }
        })
        ->process( $_POST );

    // Vérification de la présence d'une erreur dans le retour JSON
    $response = $editor->data();

    // Si une erreur est détectée, modifier le message d'erreur
    if (isset($response['error'])) {
        $response['error'] = "An error occured. Contact IT support.";
    }

    // Retourner la réponse JSON
    echo json_encode($response);

Viewing all articles
Browse latest Browse all 82801

Trending Articles