We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 50497
    • 30 Posts
    I have a bit of a noob question. I recently started using MIGX in a project and it's a first for me. Following this tutorial https://www.gelstudios.co.uk/blog/2013/10/modx-migx-db-tutorial.html I was able to create an XML schema, create the database, a CMP in which I am able to add records. No issue there.

    My question is I noticed that MIGX does indeed create a custom table in my database, visually I can see that it's there using PHPAdmin. However, when I add a new record in the CMP it displays the new record, but it's not technically added to the new database table. On the flip side if I manually insert a record into the database it's not displaying within the new CMP. Should my records show within the new mySQL table when entered in the MIGX CMP? Should my records show in the CMP when added manually to the table?

    I guess I'm a bit confused as to where it's actually storing these records that I'm entering in the CMP if they are not displaying in the database table.
      • 4172
      • 5,888 Posts
      the newly created record is stored in your mysql-table, might be you have another table with another prefix, which is used?

      first question, as allways:

      what is your MIGX-config (exported json of your MIGX-configuration for that CMP - right click at the configuration-grid)
      and your xpdo-schema.
      Please post them both here (in code-tags)
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 50497
        • 30 Posts
        No problem.
        XML Schema is as follows:

        <?xml version="1.0" encoding="UTF-8"?>
        <model package="users"
           baseClass="xPDOObject"
           platform="mysql"
           defaultEngine="MyISAM"
           version="1.1">
        <object class="user" table="user_tbl" extends="xPDOSimpleObject">
        	<field key="FK_UserId" dbtype="int" precision="20" phptype="integer" null="true" default="" />
        	<field key="fname" dbtype="varchar" precision="200" phptype="string" null="true" default="" />
        	<field key="lname" dbtype="varchar" precision="200" phptype="string" null="true" default="" />
        	<field key="jobTitle" dbtype="varchar" precision="200" phptype="string" null="true" default="" />
        	<field key="officePhone" dbtype="varchar" precision="100" phptype="string" null="true" default="" />
        	<field key="mobilePhone" dbtype="varchar" precision="100" phptype="string" null="true" default="" />
        	<field key="faxPhone" dbtype="varchar" precision="100" phptype="string" null="true" default="" />
        	<field key="streetAddress1" dbtype="varchar" precision="250" phptype="string" null="true" default="" />
        	<field key="streetAddress2" dbtype="varchar" precision="250" phptype="string" null="true" default="" />
        	<field key="city" dbtype="varchar" precision="200" phptype="string" null="true" default="" />
        	<field key="state" dbtype="varchar" precision="2" phptype="string" null="true" default="" />
        	<field key="zip" dbtype="varchar" precision="20" phptype="string" null="true" default="" />
            <field key="bio" dbtype="varchar" precision="255" phptype="string" null="true" default="" />
        	<field key="linkedin" dbtype="varchar" precision="250" phptype="string" null="true" default="" />
        	<field key="facebook" dbtype="varchar" precision="250" phptype="string" null="true" default="" />
        	<field key="twitter" dbtype="varchar" precision="250" phptype="string" null="true" default="" />
        	<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        	<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        </object>
        </model>


        and the JSON...
        {
          "formtabs":[
            {
              "MIGX_id":2,
              "caption":"User Details",
              "print_before_tabs":"0",
              "fields":[
                {
                  "MIGX_id":16,
                  "field":"id",
                  "caption":"ID",
                  "description":"",
                  "description_is_code":"0",
                  "inputTV":"",
                  "inputTVtype":"",
                  "validation":"",
                  "configs":"",
                  "restrictive_condition":"",
                  "display":"",
                  "sourceFrom":"config",
                  "sources":"",
                  "inputOptionValues":"",
                  "default":"",
                  "useDefaultIfEmpty":"0",
                  "pos":1
                },
                {
                  "MIGX_id":17,
                  "field":"FK_UserId",
                  "caption":"User ID",
                  "description":"",
                  "description_is_code":"0",
                  "inputTV":"",
                  "inputTVtype":"",
                  "validation":"",
                  "configs":"",
                  "restrictive_condition":"",
                  "display":"",
                  "sourceFrom":"config",
                  "sources":"",
                  "inputOptionValues":"",
                  "default":"",
                  "useDefaultIfEmpty":"0",
                  "pos":2
                },
                {
                  "MIGX_id":18,
                  "field":"fname",
                  "caption":"First Name",
                  "description":"",
                  "description_is_code":"0",
                  "inputTV":"",
                  "inputTVtype":"",
                  "validation":"",
                  "configs":"",
                  "restrictive_condition":"",
                  "display":"",
                  "sourceFrom":"config",
                  "sources":"",
                  "inputOptionValues":"",
                  "default":"",
                  "useDefaultIfEmpty":"0",
                  "pos":3
                },
                {
                  "MIGX_id":19,
                  "field":"lname",
                  "caption":"Last Name",
                  "description":"",
                  "description_is_code":"0",
                  "inputTV":"",
                  "inputTVtype":"",
                  "validation":"",
                  "configs":"",
                  "restrictive_condition":"",
                  "display":"",
                  "sourceFrom":"config",
                  "sources":"",
                  "inputOptionValues":"",
                  "default":"",
                  "useDefaultIfEmpty":"0",
                  "pos":4
                },
                {
                  "MIGX_id":20,
                  "field":"published",
                  "caption":"Published",
                  "description":"",
                  "description_is_code":"0",
                  "inputTV":"",
                  "inputTVtype":"checkbox",
                  "validation":"",
                  "configs":"",
                  "restrictive_condition":"",
                  "display":"",
                  "sourceFrom":"config",
                  "sources":"",
                  "inputOptionValues":"yes==1",
                  "default":1,
                  "useDefaultIfEmpty":1,
                  "pos":5
                }
              ],
              "pos":1
            }
          ],
          "contextmenus":"update||duplicate||publish||unpublish||remove",
          "actionbuttons":"addItem",
          "columnbuttons":"",
          "filters":"",
          "extended":{
            "migx_add":"Add User Details",
            "disable_add_item":"",
            "add_items_directly":"",
            "formcaption":"",
            "update_win_title":"",
            "win_id":"userdetails",
            "maxRecords":"",
            "addNewItemAt":"bottom",
            "multiple_formtabs":"",
            "multiple_formtabs_label":"",
            "multiple_formtabs_field":"",
            "multiple_formtabs_optionstext":"",
            "multiple_formtabs_optionsvalue":"",
            "actionbuttonsperrow":4,
            "winbuttonslist":"",
            "extrahandlers":"",
            "filtersperrow":4,
            "packageName":"users",
            "classname":"user",
            "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":"",
            "hooksnippets":"",
            "cmpmaincaption":"User Details",
            "cmptabcaption":"User Details",
            "cmptabdescription":"Add, View or Edit User Details",
            "cmptabcontroller":"",
            "winbuttons":"",
            "onsubmitsuccess":"",
            "submitparams":""
          },
          "columns":[
            {
              "MIGX_id":4,
              "header":"ID",
              "dataIndex":"id",
              "width":"",
              "sortable":"false",
              "show_in_grid":1,
              "renderer":"",
              "clickaction":"",
              "selectorconfig":"",
              "renderchunktpl":"",
              "renderoptions":"",
              "editor":""
            },
            {
              "MIGX_id":1,
              "header":"User ID",
              "dataIndex":"FK_UserId",
              "width":10,
              "sortable":"false",
              "show_in_grid":1,
              "renderer":"",
              "clickaction":"",
              "selectorconfig":"",
              "renderchunktpl":"",
              "renderoptions":"",
              "editor":""
            },
            {
              "MIGX_id":2,
              "header":"First Name",
              "dataIndex":"fname",
              "width":"",
              "sortable":"false",
              "show_in_grid":1,
              "renderer":"",
              "clickaction":"",
              "selectorconfig":"",
              "renderchunktpl":"",
              "renderoptions":"",
              "editor":""
            },
            {
              "MIGX_id":3,
              "header":"Last Name",
              "dataIndex":"lname",
              "width":"",
              "sortable":"false",
              "show_in_grid":1,
              "renderer":"",
              "clickaction":"",
              "selectorconfig":"",
              "renderchunktpl":"",
              "renderoptions":"",
              "editor":""
            },
            {
              "MIGX_id":5,
              "header":"Published",
              "dataIndex":"published",
              "width":"",
              "sortable":"false",
              "show_in_grid":1,
              "renderer":"this.renderCrossTick",
              "clickaction":"",
              "selectorconfig":"",
              "renderchunktpl":"",
              "renderoptions":"",
              "editor":""
            }
          ]
        }


        I only created a few of the fields in the form for testing purposes. I didn't want to add all the fields at one time and have something break. I figured adding them a few at a time would be easier to troubleshoot.
          • 50497
          • 30 Posts
          Bruno,
          Thank you so much for your help. Your simple comment helped me track it down. It was a relatively simply oversight on my part. Here's what happened for those interested.

          When setting up the package within MIGX I changed the table-prefix from "Default" to "Custom" and added a custom-prefix of "site_". I did not want to have the modx_ prefix added to this particular table. However, in my schema I added omitted the prefix on the table.

          <object class="user" table="user_tbl" extends="xPDOSimpleObject">


          should have read...

          <object class="user" table="site_user_tbl" extends="xPDOSimpleObject">


          When I clicked the Create Tables link within package manager it created the site_user_tbl, however modx_user_tbl was created as well.
            • 4172
            • 5,888 Posts
            yeah, if you have a custom-prefix, you allways need to put that prefix into the input-field in the MIGX - package-manager-CMP when doing table-operations and everywhere.

            It happend to often to me, that I forgot about custom-prefixes.
            That's the reason, why I'm allways using the default table-prefix now, if possible.
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!