DataTables Editor installed via Composer

DataTables Editor installed via Composer

scratcherscratcher Posts: 2Questions: 1Answers: 0

How to use DataTables Editor installed via Composer?

use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Mjoin,
DataTables\Editor\Options,
DataTables\Editor\Upload,
DataTables\Editor\Validate,
DataTables\Editor\ValidateOptions;

require '../config.php';
require '../vendor/autoload.php';

Editor::inst( $db, 'filters' )
->fields(
...
and getting errors like: Uncaught Error: Call to a member function transaction() on null, because $db is NULL.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,992Questions: 1Answers: 10,367 Site admin
    Answer ✓

    Hi,

    When you do a Composer install, you need to make the database connection yourself. As you'll see in the documentation that is typically something like:

    $db = new DataTables\Database( array(
        "type" => "...",
        ...
    ) );
    

    You could put that into config.php if you want to to allow it to be shared between files.

    Allan

  • scratcherscratcher Posts: 2Questions: 1Answers: 0

    Thanks, Allan!

This discussion has been closed.