We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19328
    • 433 Posts
    Hi, I've got a MIGX tv to create a sidebar. I've set it up using the configurator. However, after adding some values to the tv and saving the page several times, refreshing etc., sometimes the content of the tv is suddenly gone. Also the entire entry in the database has disappeared at that point.

    The export data of the config is:
    {
      "formtabs":"",
      "contextmenus":"",
      "actionbuttons":"",
      "columnbuttons":"",
      "filters":"",
      "extended":{
        "migx_add":"Voeg widget toe",
        "disable_add_item":"",
        "formcaption":"Widgets",
        "update_win_title":"Widgets",
        "win_id":"migx_widgets",
        "maxRecords":"",
        "addNewItemAt":"bottom",
        "multiple_formtabs":"10||6||9||7",
        "actionbuttonsperrow":4,
        "winbuttonslist":"",
        "extrahandlers":"",
        "filtersperrow":4,
        "packageName":"",
        "classname":"",
        "task":"",
        "getlistsort":"",
        "getlistsortdir":"",
        "sortconfig":"",
        "gridpagesize":"",
        "use_custom_prefix":"0",
        "prefix":"",
        "grid":"",
        "gridload_mode":1,
        "check_resid":1,
        "check_resid_TV":"",
        "join_alias":"",
        "has_jointable":"yes",
        "getlistwhere":"",
        "joins":"",
        "cmpmaincaption":"",
        "cmptabcaption":"",
        "cmptabdescription":"",
        "cmptabcontroller":"",
        "winbuttons":"",
        "onsubmitsuccess":"",
        "submitparams":""
      },
      "columns":[
        {
          "MIGX_id":1,
          "header":"Titel widget",
          "dataIndex":"titel",
          "width":"",
          "sortable":"false",
          "show_in_grid":1,
          "renderer":"",
          "clickaction":"",
          "selectorconfig":"",
          "renderchunktpl":"",
          "renderoptions":""
        }
      ]
    }
    


    When I save some entries in this tv the tv contentvalue is:

    [{"MIGX_id":"1","MIGX_formname":"bestaande_widget","titel":"12"},{"MIGX_id":"2","MIGX_formname":"bestaande_widget","titel":"17"}]
    


    In the error log I sometimes get these errors:

    [2014-08-01 12:22:18] (ERROR @ /home/pfcy21dssd76/domains/mywebsite.nl/public_html/core/components/migx/model/migx/migx.class.php : 1911) PHP warning: Invalid argument supplied for foreach()


    I first thought this had to do with using renderChunk for a column, but I removed that and the problem persists.

    What could be causing this? It's quite scary that all content can disappear like this, wouldn't want that to happen to my client. Thanks for any help! [ed. note: michelle84 last edited this post 12 years, 2 months ago.]
      • 19328
      • 433 Posts
      Bruno helped me with this problem, he discovered what I had done wrong: I had used a default value for this TV, which was a @SELECT binding to get the value of.. the same TV. When the value of a TV is the same as the default value, it is removed by MODX from the database.

      I made this 'strange' construction because I wanted to achieve the following:
      - on a settings page the user can set default values in this TV
      - when he creates a resource (which has the same TV attached) there are already default values in the TV (taken from the settings page with the @SELECT binding). So he doesn't have to change it if he doesn't want to. (in this case, the TV holds widgets for the sidebar).
      - but the user can also change the TV for the specific resource (for example to remove some widgets on a particular resource).

      In my head this seemed so logical, but for the settings page it couldn't work because the default value would be taken from the same resource + TV.

      I think I have a new solution now, by creating two TVs:
      1) global_widgets (only attached to the settings page, no default value)
      2) resource_widgets (only attached to the article pages template, default value = @SELECT to get the value of the global_widgets TV.

      I'm going to test some more but I think this will stop the unwanted behavior because it are 2 different TVs now.

      Thank you Bruno for your help!