Problem With Datatables Editor Generator

Problem With Datatables Editor Generator

crush123crush123 Posts: 417Questions: 126Answers: 18

Just downloaded the trial of this, but am struggling a bit.

As an initial test, i used the default data, connected to the 'users' table and used the primary key field and three others.

Downloaded the complete package - it works

I then connected to one of my own tables, tblcoupons, currently working ok with datatables

The package was created in the same way, but when I load the page, I get an error

SQLSTATE[42S22] 1054 Unknown column 'id' in 'field list'

The primary key is not called 'id' it is CouponID, and I used this in the generator.

There is no field with this name in the table, but cant see why it is being referenced

I searched for 'id' in the downloaded pages but can;t find it

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Answer ✓

    Hi,

    Sorry for the problems. I'll take a look into the Generator issue, but for the moment, if you open the PHP file that Generator creates and edit the line Editor::inst(...). The inst() function should be given three parameters when you want to use a primary key that is not id. The third parameter tells Editor what to use - in this case you want something like:

    Editor::inst( $db, 'myTable', 'CouponID' )
    

    Regards,
    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18
    edited May 2014

    Thats it, I added the third parameter corresponing to the PK, and the data now loads successfully

    Thanks

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    Another possible problem with the generator,

    When I chose date as a field type, validation required, and left the default format, I got a parse error in my generated php

    I got

    ->validator( 'Validate::dateFormat, array( 'empty' => false )', 'D, j M y' )
    ->getFormatter( 'Format::date_sql_to_format', 'D, j M y' )
    ->setFormatter( 'Format::date_format_to_sql', 'D, j M y' ),

    instead of

    ->validator( 'Validate::dateFormat', 'D, d M y' )
    ->getFormatter( 'Format::date_sql_to_format', 'D, d M y' )
    ->setFormatter( 'Format::date_format_to_sql', 'D, d M y' ),

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thanks for pointing that out. I'll take a look at it very shortly.

    Allan

This discussion has been closed.