Fork me on GitHub

Add Standard fields  Bottom

  • Hi everybody.

    I created a module for my site with a table without standard fields of zikula. Now i want update the module and add the standard fields.
    I have tried with this code in pninit.php, but the table was not updated.

    Code

    ObjectUtil::addStandardFieldsToTableDefinition ($tables['Mapas_column'], 'z_');
    ObjectUtil::addStandardFieldsToTableDataDefinition($tables['Mapas_column_def']);


    I have tried add these lines in the pntables too, and in the pninit.php I wrote

    Code

    DBUtil::ChangeTable('Mapas');


    But the fields are not added to the table.

    What's wrong? How can I add the standard fields to my table in a update of the module?

    Thanks.
  • You have to make sure you make a new version of the module where the upgrade section to that new version takes care of the Changetable and hence adding the fields. The addstandard.. lines seem ok.

    So it should work, I'm not sure if changetable recognizes hte new standard fields though..

    --
    campertoday.nl, Module development, Dutch Zikula Community
  • Thanks espaan.

    Yes, my initial version was 0.1. I has this source code (and other lines that was executed successfully), but the table was not was changed.

    I have tried this two o three times (modify the _module table), but it dont working.

    Any idea?

    Thanks.
  • I don't think the 'z_' is correct in

    Code

    ObjectUtil::addStandardFieldsToTableDefinition ($tables['Mapas_column'], 'z_');


    Assuming this is a 1.2.x module, the 'z_' prefix (the table prefix for the entire module) is handled automatically.
    The prefix it is looking for there is whatever prefix, if any, you add to all the COLUMNS in this table.

    I suggest changing the pninit code to:

    Code

    if ( !DBUtil::changeTable('School_family') ) return false;


    which will at least fail if there is an error.
  • Hi everybody!

    Thanks for all! I found the error! A stupid error!
    In my pntables i had written:

    Code

    $pntable = array();
    $pntable['Mapas'] = DBUtil::getLimitedTablename('Mapas');
    ....
    // add standard data fields
    ObjectUtil::addStandardFieldsToTableDefinition ($tables['Mapas_column']);
    ObjectUtil::addStandardFieldsToTableDataDefinition($tables['Mapas_column_def']);

    So...CAUTION WITH THE COPY&PASTE!!! icon_razz
    The problem was the variable, pntable -> tables...UUUOPPPSSS doh

    Thanks!
  • icon_biggrin good that you found it after all

    --
    campertoday.nl, Module development, Dutch Zikula Community

This list is based on users active over the last 60 minutes.