Am I right to use Generator`s "get" & "set" options ?

Am I right to use Generator`s "get" & "set" options ?

VitalizVitaliz Posts: 71Questions: 7Answers: 1
edited November 2013 in Editor
I have create datatables form, there I want to have the Editing interface show more detail than in the table. MySQL table 12 columns, but only 8 need to browse. As is described in Generator`s docs, If "get" in current line not checked then the value is not shown in the DataTable but is still available to Editor,i.e. visible, editable and can be saved to database. When I generate this table, I was uncheck gets for 4 little importance fields. Other gets and sets was checked.
I install complete package to test server: http://put-k-diplomu.ru/avtors-tst/Avtors.html
When I add new record, all bee right, but when I start edit this record, I can`t see "get-less" fields(where "get" was unchecked in Generator`s window) values in Editor`s window. When I edit this fields, it`s values are stored in database, but stay unvisible then edit screen starts next time.
What should be done to fix this situation?

Vitaliy.

DataTables debugger`s cod is adejez.

Replies

  • allanallan Posts: 61,662Questions: 1Answers: 10,094 Site admin
    This is a very good point - I think the get and set options are a bit confusing to be honest (and I wrote them!). I'm going to replace them with `Table` and `Editor` options which I think will meet exactly what you are looking for.

    Until then (very soon I hope!), you'll need to add the fields that you want into the PHP fields array in the script that Generator built. The data isn't being obtained from the database at the moment which is why they aren't been shown. What does your PHP script look like?

    Thanks,
    Allan
  • VitalizVitaliz Posts: 71Questions: 7Answers: 1
    Hi,Allan.
    Thanks for replay.

    It`s here:
    [code]
    <?php

    /*
    * Editor server script for DB table Avtors
    * Automatically generated by http://editor.datatables.net/generator
    */

    // DataTables PHP library
    include( "lib/DataTables.php" );

    // Alias Editor classes so they are easy to use
    use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Join,
    DataTables\Editor\Validate;


    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'Avtors' )
    ->fields(
    Field::inst( 'kod_avt' )
    ->get( false ),
    Field::inst( 'fio_avt' ),
    Field::inst( 'fone_avt' )
    ->get( false ),
    Field::inst( 'mail_avt' )
    ->get( false )
    ->validator( 'Validate::email' ),
    Field::inst( 'smax_avt' ),
    Field::inst( 'snorm_avt' ),
    Field::inst( 'anti_avt' ),
    Field::inst( 'rpret_avt' ),
    Field::inst( 'rsrok_avt' ),
    Field::inst( 'rstoim_avt' ),
    Field::inst( 'rtot_avt' ),
    Field::inst( 'dopinf_avt' )
    ->get( false )
    )
    ->process( $_POST )
    ->json();

    [/code]
  • allanallan Posts: 61,662Questions: 1Answers: 10,094 Site admin
    Thanks - I think you should remove the `get( false )` calls. That will allow the data to be fetched for use in the form, but not displayed in the table.

    Allan
  • VitalizVitaliz Posts: 71Questions: 7Answers: 1
    edited November 2013
    Thanks,Allan. You are absolutely right. I had previously tried to correct PHP script, without get unchecking,but got some problems. Your advice really work and is very easy.

    Vitaliy.
  • allanallan Posts: 61,662Questions: 1Answers: 10,094 Site admin
    Hi Vitaliy,

    I've just altered Generator to have "Table" and "Editor" options rather than "Get" and "Set", as I think the new options will be a lot more useful and more obvious. Thanks for bringing this point up and the discussion!

    Regards,
    Allan
  • VitalizVitaliz Posts: 71Questions: 7Answers: 1
    edited November 2013
    Hi, Allan. So quickly ... I'm surprised.

    Just tested. Works from the box), without editing. Great.

    Thanks, it just I need.(And others too, I think)

    Vitaliy.

    P.S.
    I understand that the generator is the starter package, but it was great for the newbees (like me) to be able to keep their projects on the disk and load on the need for change data structure and cloning projects
This discussion has been closed.