Upload Unknown file table name

Upload Unknown file table name

marco.digioiamarco.digioia Posts: 8Questions: 4Answers: 0

Hi,

i have a simple page with a record for upload a file.
The server-side code is:

    Editor::inst( $db, 'kedb_documents' )
            ->fields(
        Field::inst( 'ID'),
                Field::inst( 'PROJECT' ),
                Field::inst( 'NAME' ),
                Field::inst( 'ARGUMENT' ),
                Field::inst( 'KEYWORD' ),
                Field::inst( 'DESCRIPTION' ),
                Field::inst( 'NOTE' ),
                Field::inst( 'FILENAME' )
        ->upload( Upload::inst( '/home/documents/__ID__.__EXTN__' ) )
        ->setFormatter( 'Format::nullEmpty' )
            )
            ->process( $_POST )
            ->json();

and the client-side cose is:

fields: [
{....},
     {
      label: "Filename",
      name: "FILENAME",
      type: "upload",
      display: function ( val ) {
          return table.file( 'kedb_documents', "ID" ).fileName;
      }
    }
        ]

when i try to edit the row the error returned is "Unknown file table name kedb_documents". Why?
Thank you

Answers

  • allanallan Posts: 47,045Questions: 1Answers: 6,628 Site admin

    The error message is a little misleading there - apologies. The issue is that there is no Upload->db() call which will give the upload class information about the database table to store the file meta information.

    Detailed information about that can be found in the documentation.

    Allan

  • marco.digioiamarco.digioia Posts: 8Questions: 4Answers: 0
    Fatal error: Call to undefined method DataTables\Editor\Field::db() in .../php/table.kedb_documents.php on line 30
    

    whe i add the code below

        Field::inst( 'FILENAME' )
            ->upload( Upload::inst( '/svn/bc_repo/Supporto/Documentazione/__ID__.__EXTN__' ) )
            ->setFormatter( 'Format::nullEmpty' )
            ->db( 'kedb_documents', 'ID', array(
                    'FILENAME' => Upload::DB_FILE_NAME
                ))
    

    Where am I doing wrong? The line 30 is ->db(

  • allanallan Posts: 47,045Questions: 1Answers: 6,628 Site admin

    There isn't a Field->db() method - the db() method is on the Upload class.

    If you scroll down the page a little from the link I gave above it shows an example.

    Allan

  • marco.digioiamarco.digioia Posts: 8Questions: 4Answers: 0

    thanks. i add the pack, and try again

  • marco.digioiamarco.digioia Posts: 8Questions: 4Answers: 0

    it's all ok

Sign In or Register to comment.