Class 'DataTables\Editor' not found

Class 'DataTables\Editor' not found

passyguypassyguy Posts: 1Questions: 1Answers: 0
edited February 2017 in Free community support

Hi I have a problem that since disturb me. I try to follow one of your examples by applying a database I have created.

But the following one appears after compilation : <b>Fatal error</b>: Class '    DataTables\Editor' not found in <b>C:\xampp\htdocs\luxeshop\categorie.php</b> on line <b>17</b><br />

Here is my php file.

<?php
/* * Example PHP implementation used for the index.html example
 */
// DataTables PHP library
//include '../../php/DataTables.php';
// Alias Editor classes so they are easy to use
include ("../../php/DataTables.php");
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
        Editor::inst( $db, 'categories' )
    ->fields(
         Field::inst( 'id' ),
         Field::inst( 'categorie' )->validator('Validate::notEmpty' ),
         Field::inst( 'id_parent' )->validator('Validate::notEmpty' )
    )
    ->process( $_POST )
    ->json();

and my html file

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="shortcut icon" type="image/ico" href="http://www.datatables.net/favicon.ico">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="extensions/Buttons/css/buttons.bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="extensions/Select/css/select.bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="extensions/Editor/css/editor.bootstrap.min.css">

    <style type="text/css" class="init">

    </style>
    <script type="text/javascript" language="javascript" src="js/jquery.js">
    </script>
    <script type="text/javascript" language="javascript" src="js/bootstrap.min.js">
    </script>
    <script type="text/javascript" language="javascript" src="js/jquery.dataTables.min.js">
    </script>
    <script type="text/javascript" language="javascript" src="js/dataTables.bootstrap.min.js">
    </script>
    <script type="text/javascript" language="javascript" src="extensions/Buttons/js/dataTables.buttons.min.js">
    </script>
    <script type="text/javascript" language="javascript" src="extensions/Buttons/js/buttons.bootstrap.min.js">
    </script>
    <script type="text/javascript" language="javascript" src="extensions/Select/js/dataTables.select.min.js">
    </script>
    <script type="text/javascript" language="javascript" src="extensions/Editor/js/dataTables.editor.min.js">
    </script>
    <script type="text/javascript" language="javascript" src="extensions/Editor/js/editor.bootstrap.min.js">
    </script>
<script type="text/javascript" language="javascript" class="init">

var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
    editor = new $.fn.dataTable.Editor( {
        ajax: "categorie.php",
        table: "#tblcat",
        fields: [ {
                label: "ID:",
                name: "id"
            },
       {
                label: "Catégories:",
                name: "categorie"
            },
      {
                label: "Parents:",
                name: "id_parent"
            }
        ]
    } );

    var table = $('#tblcat').DataTable( {
        lengthChange: false,
        ajax: "categorie.php",
        columns: [

            //{ data: "id" },
            { data: "categorie" },
            { data: "id_parent" }
        ],
        select: true
    } );

    // Display the buttons
    new $.fn.dataTable.Buttons( table, [
        { extend: "create", editor: editor },
        { extend: "edit",   editor: editor },
        { extend: "remove", editor: editor }
    ] );

    table.buttons().container()
        .appendTo( $('.col-sm-6:eq(0)', table.table().container() ) );
} );
    </script>
</head>
<body >
            <div class="demo-html"></div>
            <table id="tblcat" class="table table-striped table-bordered" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Catégories</th>
                        <th>Parents</th>

                    </tr>
                </thead>
                <tfoot>
                    <tr>
                        <th>ID</th>
                        <th>Catégories</th>
                        <th>Parents</th>
                    </tr>
                </tfoot>
            </table>
</body>
</html>

Answers

  • allanallan Posts: 63,850Questions: 1Answers: 10,519 Site admin

    Sounds like the classes aren't being loaded for some reason. What version of PHP are you using?

    What happens if you change:

    include ("../../php/DataTables.php");
    

    to be:

    require ("../../php/DataTables.php");
    

    (I'm just trying to ensure that file is correctly loaded).

    Allan

This discussion has been closed.