<![CDATA[ Help with simple many-to-many nested migxdb CMP - My Forums]]> https://forums.modx.com/thread/?thread=96409 <![CDATA[Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-521761
I created a simple test staff, categories, staff/categories schema and CMP configs and have it almost working. New staff records are saving as well as the staff/categories records but the staff/categories table is not saving the ID of the current staff member, just a 0 value. I believe the join is working correctly as I was able to add test columns to the nested migxdb referencing back to the category name and staff name (when I manually set the staff ID). Anyone know what am I doing wrong?

Here is the schema that I am using:

<?xml version="1.0" encoding="UTF-8"?> 
<model package="staff" baseClass="xPDOObject" platform="mysql" defaultEngine="InnoDB" version="1.1"> 
	<object class="StaffMember" table="staff_members" extends="xPDOSimpleObject" > 
		<field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default="" /> 
		<composite alias="StaffMemberCategories" class="StaffMemberCategories" local="id" foreign="staff_id" cardinality="many" owner="local" />		
	</object> 
	<object class="StaffCategory" table="staff_categories" extends="xPDOSimpleObject" > 
		<field key="category" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
		<composite alias="StaffMemberCategories" class="StaffMemberCategories" local="id" foreign="category_id" cardinality="many" owner="local" />		
	</object> 
	<object class="StaffMemberCategories" table="staff_member_categories" extends="xPDOSimpleObject" > 
		<field key="staff_id" dbtype="int" precision="11" phptype="integer" null="false" default="0" /> 
		<field key="category_id" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
		<aggregate alias="StaffMembers" class="StaffMember" local="staff_id" foreign="id" cardinality="one" owner="foreign" />
	        <aggregate alias="StaffCategories" class="StaffCategory" local="category_id" foreign="id" cardinality="one" owner="foreign" />
	</object> 
</model>


Config for staff_members:
{
  "formtabs":[
    {
      "MIGX_id":8,
      "caption":"New Staff Member",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":22,
          "field":"name",
          "caption":"Staff Name",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
        {
          "MIGX_id":23,
          "field":"staffmembercategories",
          "caption":"Staff Categories",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"migxdb",
          "validation":"",
          "configs":"staff_member_categories",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        }
      ],
      "pos":1
    }
  ],
  "contextmenus":"update||duplicate||publish||unpublish||remove",
  "actionbuttons":"addItem",
  "columnbuttons":"update||duplicate||publish||unpublish||remove",
  "filters":"",
  "extended":{
    "migx_add":"Add New Staff Member",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"staff_members",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":4,
    "winbuttonslist":"",
    "extrahandlers":"",
    "filtersperrow":4,
    "packageName":"staff",
    "classname":"StaffMember",
    "task":"",
    "getlistsort":"",
    "getlistsortdir":"",
    "sortconfig":"",
    "gridpagesize":"",
    "use_custom_prefix":"0",
    "prefix":"",
    "grid":"",
    "gridload_mode":2,
    "check_resid":1,
    "check_resid_TV":"",
    "join_alias":"",
    "has_jointable":"yes",
    "getlistwhere":"",
    "joins":"",
    "cmpmaincaption":"Staff Members",
    "cmptabcaption":"All Staff Members",
    "cmptabdescription":"",
    "cmptabcontroller":"",
    "winbuttons":"",
    "onsubmitsuccess":"",
    "submitparams":""
  },
  "columns":[
    {
      "MIGX_id":1,
      "header":"ID",
      "dataIndex":"id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Staff Name",
      "dataIndex":"name",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    }
  ]
}


Config for staff_members_categories (with extra test columns):
{
  "formtabs":[
    {
      "MIGX_id":9,
      "caption":"Staff Categories",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":24,
          "field":"category_id",
          "caption":"Category",
          "description":"",
          "description_is_code":"0",
          "inputTV":"staff_categories",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        }
      ],
      "pos":1
    }
  ],
  "contextmenus":"update||remove",
  "actionbuttons":"addItem",
  "columnbuttons":"update||remove",
  "filters":"",
  "extended":{
    "migx_add":"",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"staff_member_categories",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":4,
    "winbuttonslist":"",
    "extrahandlers":"",
    "filtersperrow":4,
    "packageName":"staff",
    "classname":"StaffMemberCategories",
    "task":"",
    "getlistsort":"",
    "getlistsortdir":"",
    "sortconfig":"",
    "gridpagesize":"",
    "use_custom_prefix":"0",
    "prefix":"",
    "grid":"",
    "gridload_mode":2,
    "check_resid":"0",
    "check_resid_TV":"",
    "join_alias":"",
    "has_jointable":"no",
    "getlistwhere":"",
    "joins":[
      {
        "alias":"StaffMembers"
      },
      {
        "alias":"StaffCategories"
      }
    ],
    "cmpmaincaption":"",
    "cmptabcaption":"",
    "cmptabdescription":"",
    "cmptabcontroller":"",
    "winbuttons":"",
    "onsubmitsuccess":"",
    "submitparams":""
  },
  "columns":[
    {
      "MIGX_id":1,
      "header":"ID",
      "dataIndex":"id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Staff ID",
      "dataIndex":"staff_id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":3,
      "header":"Category ID",
      "dataIndex":"category_id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":4,
      "header":"Staff Table ID",
      "dataIndex":"StaffMembers_id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":5,
      "header":"Staff Name",
      "dataIndex":"StaffMembers_name",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":6,
      "header":"Category Name",
      "dataIndex":"StaffCategories_category",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    }
  ]
}
]]>
khansen Mar 03, 2015, 01:18 PM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-521761
<![CDATA[Re: Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-552851
[2017-07-29 00:05:50] (ERROR @ /paas/c0246/www/core/xpdo/om/xpdoobject.class.php : 1452) Error 23000 executing statement:
INSERT INTO `modx_product_colors_product` (`modx_product_id`, `modx_product_color_id`) VALUES (0, 1)
Array
(
    [0] => 23000
    [1] => 1452
    [2] => Cannot add or update a child row: a foreign key constraint fails (`instance_c0246_modx`.`modx_product_colors_product`, CONSTRAINT `modx_product_colors_product_modx_product_id_foreign` FOREIGN KEY (`modx_product_id`) REFERENCES `modx_products` (`id`))
)

and that is my schema ::
<?xml version="1.0" encoding="UTF-8"?>
<model package="Fcommerce" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="ProductColorsProduct" table="product_colors_product" extends="xPDOSimpleObject">
		<field key="modx_product_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="index" />
		<field key="modx_product_color_id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="index" />

		<index alias="modx_product_colors_product_modx_product_id_foreign" name="modx_product_colors_product_modx_product_id_foreign" primary="false" unique="false" type="BTREE" >
			<column key="modx_product_id" length="" collation="A" null="false" />
		</index>
		<index alias="modx_product_colors_product_modx_product_color_id_foreign" name="modx_product_colors_product_modx_product_color_id_foreign" primary="false" unique="false" type="BTREE" >
			<column key="modx_product_color_id" length="" collation="A" null="false" />
		</index>
		<aggregate alias="ProductColors" class="ProductColors" local="modx_product_color_id" foreign="id" cardinality="one" owner="foreign" />
		<aggregate alias="Products" class="Products" local="modx_product_id" foreign="id" cardinality="one" owner="foreign" />
</object>
<object class="Products" table="products" extends="xPDOSimpleObject">
		<field key="product_number" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="true" />
		<field key="price" dbtype="double" precision="8,2" phptype="float" null="false" />
		<field key="size_width" dbtype="double" precision="8,2" phptype="float" null="false" />
		<field key="size_height" dbtype="double" precision="8,2" phptype="float" null="false" />
		<field key="title" dbtype="varchar" precision="200" phptype="string" null="false" />
		<field key="description" dbtype="varchar" precision="255" phptype="string" null="true" />
		<field key="link" dbtype="varchar" precision="255" phptype="string" null="false" />
		<field key="quantity" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="100" />
		<field key="quality" dbtype="varchar" precision="255" phptype="string" null="true" />
		<field key="sort" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
		<field key="product_material" dbtype="varchar" precision="255" phptype="string" null="true" />
		<field key="product_typ" dbtype="varchar" precision="100" phptype="string" null="false" />
		<field key="color" dbtype="varchar" precision="255" phptype="string" null="false" default="white" />
		<field key="operation_type" dbtype="enum" precision="'Handmatig','Electrisch'" phptype="string" null="false" />
		<field key="available_operation" dbtype="tinyint" precision="1" phptype="integer" null="false" default="1" />
		<field key="remote_control_quantity" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
		<field key="remote_control_type" dbtype="varchar" precision="255" phptype="string" null="false" default="1-kanaals handzender" />
		<field key="certificate" dbtype="tinyint" precision="1" phptype="integer" null="false" default="0" />
		<field key="published" dbtype="tinyint" precision="1" phptype="integer" null="false" default="0" />
		<field key="created_at" dbtype="timestamp" phptype="timestamp" null="true" />
		<field key="updated_at" dbtype="timestamp" phptype="timestamp" null="true" />
		<aggregate alias="ProductImages" class="ProductImages" local="id" foreign="modx_product_id" cardinality="many" owner="local" />
		<aggregate alias="ProductSizeProduct" class="ProductSizeProduct" local="id" foreign="modx_product_id" cardinality="many" owner="local" />
		<aggregate alias="ProductColorsProduct" class="ProductColorsProduct" local="id" foreign="modx_product_id" cardinality="many" owner="local" />
	</object>
<object class="ProductColors" table="product_colors" extends="xPDOSimpleObject">
		<field key="color_name" dbtype="varchar" precision="100" phptype="string" null="false" />
		<field key="color_image" dbtype="varchar" precision="255" phptype="string" null="false" />
		<field key="color_code" dbtype="varchar" precision="20" phptype="string" null="false" />
		<field key="color_price" dbtype="double" precision="8,3" phptype="float" null="false" />
		<field key="quantity" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="100" />
		<aggregate alias="ProductColorsProduct" class="ProductColorsProduct" local="id" foreign="modx_product_color_id" cardinality="many" owner="local" />
	</object>
</model>


And here is my config of my migx ::

{
  "formtabs":[
    {
      "MIGX_id":18,
      "caption":"Product color",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":79,
          "field":"modx_product_color_id",
          "caption":"Color",
          "description":"",
          "description_is_code":"0",
          "inputTV":"product_color",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"@EVAL return $modx->runSnippet('migxLoopCollection',array('packageName'=>'Fcommerce','classname'=>'ProductColors','outputSeparator'=>'||','where'=>'{\\\"published\\\":\\\"1\\\"}','tpl'=>'@CODE:[[+color_name]]==[[+id]]'));",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        }
      ]
    }
  ],
  "contextmenus":"update||remove",
  "actionbuttons":"addItem",
  "columnbuttons":"update||remove",
  "filters":"",
  "extended":{
    "migx_add":"",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"ProductColorsProduct",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":4,
    "winbuttonslist":"",
    "extrahandlers":"this.preview||this.activateObject||this.deactivateObject",
    "filtersperrow":4,
    "packageName":"Fcommerce",
    "classname":"ProductColorsProduct",
    "task":"",
    "getlistsort":"",
    "getlistsortdir":"",
    "sortconfig":"",
    "gridpagesize":"",
    "use_custom_prefix":"0",
    "prefix":"",
    "grid":"",
    "gridload_mode":2,
    "check_resid":"0",
    "check_resid_TV":"",
    "join_alias":"",
    "has_jointable":"no",
    "getlistwhere":"",
    "joins":[
      {
        "alias":"Products"
      },
      {
        "alias":"ProductColors"
      }
    ],
    "hooksnippets":{
      "aftersave":"product_colors_products_aftersave"
    },
    "cmpmaincaption":"Kleuren",
    "cmptabcaption":"Gekoeze kleuren ",
    "cmptabdescription":"Slelect kleur",
    "cmptabcontroller":"",
    "winbuttons":"",
    "onsubmitsuccess":"",
    "submitparams":""
  },
  "columns":[
    {
      "MIGX_id":1,
      "header":"ID",
      "dataIndex":"id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Product id",
      "dataIndex":"modx_product_id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":3,
      "header":"Color id",
      "dataIndex":"modx_product_color_id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":6,
      "header":"Product tabel id",
      "dataIndex":"Products_id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":4,
      "header":"Product name",
      "dataIndex":"Products_title",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":5,
      "header":"Product Color",
      "dataIndex":"ProductColors_color_name",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "customrenderer":"",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    }
  ]
}

Can some tel me how can i fixe this, thanx.

Rey]]>
hurby Jul 29, 2017, 10:13 AM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-552851
<![CDATA[Re: Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522606 dopeless Mar 15, 2015, 12:17 PM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522606 <![CDATA[Re: Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522601
change:
'tpl'=>'@CODE:[[+format]]'


to
'tpl'=>'@CODE:[[+format]]==[[+id]]'


in the intputOptionValues]]>
Bruno17 Mar 15, 2015, 10:58 AM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522601
<![CDATA[Re: Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522590 Quote from: Bruno17 at Mar 15, 2015, 06:26 AM
what is your MIGX - config?

Hi, Bruno, here is my config:

{
  "formtabs":[
    {
      "MIGX_id":1,
      "caption":"Price",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":1,
          "field":"formatId",
          "caption":"Format",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"listbox",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"@EVAL return $modx->runSnippet('migxLoopCollection',array('packageName'=>'flyerPricelist','classname'=>'fplFormats','outputSeparator'=>'||','where'=>'{\"published\":\"1\"}','tpl'=>'@CODE:[[+format]]'));",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        }
      ],
      "pos":1
    }
  ],
  "contextmenus":"update||duplicate||publish||unpublish||remove",
  "actionbuttons":"addItem",
  "columnbuttons":"update||duplicate||publish||unpublish||remove",
  "filters":"",
  "extended":{
    "migx_add":"",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"flyerPricelist",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":4,
    "winbuttonslist":"",
    "extrahandlers":"",
    "filtersperrow":4,
    "packageName":"flyerPricelist",
    "classname":"fplPrices",
    "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":{
      "aftersave":"flyer_pricelist_aftersave"
    },
    "cmpmaincaption":"Pricelist",
    "cmptabcaption":"Pricelist",
    "cmptabdescription":"Pricelist",
    "cmptabcontroller":"",
    "winbuttons":"",
    "onsubmitsuccess":"",
    "submitparams":""
  },
  "columns":[
    {
      "MIGX_id":1,
      "header":"ID",
      "dataIndex":"id",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":2,
      "header":"Format",
      "dataIndex":"formatId",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    }
  ]
}

]]>
dopeless Mar 15, 2015, 08:34 AM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522590
<![CDATA[Re: Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522573 Can you post an export of your configuration?

About co_id:

If you have a nested MIGX-grid inside another one, this is the id of the current outer object (id of connected object)]]>
Bruno17 Mar 15, 2015, 01:26 AM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522573
<![CDATA[Re: Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522558
have two classes:

<?xml version="1.0" encoding="UTF-8"?>
<model package="flyerPricelist" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
    <object class="fplPrices" table="migx_fpl_prices" extends="xPDOSimpleObject" >
        <field key="formatId" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default=""/>
        <aggregate alias="format" class="fplFormats" local="formatId" foreign="id" cardinality="one" owner="foreign"/>
    </object>
    
    <object class="fplFormats" table="migx_fpl_formats" extends="xPDOSimpleObject" >
        <field key="format" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
        <composite alias="formatId" class="fplPrices" local="id" foreign="formatId" cardinality="many" owner="local" />
    </object>
</model>


I'm loading formats from fplFormats as a listbox but want to save an id from migx_fpl_formats to migx_fpl_prices and it does not work. Can't figure out what am I doing wrong. Thnx.

Btw, what is co_id? in the snippet code?]]>
dopeless Mar 14, 2015, 06:05 PM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522558
<![CDATA[Re: Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522523 khansen Mar 13, 2015, 09:31 PM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-522523 <![CDATA[Re: Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-521772
Is this the proper way for saving a many-to-many record? I feel like this is something that is easy to do and I'm not seeing the steps/configurations that are needed to do it.

The basic workflow that I'm trying to setup is: Click Add Member->Enter name, title, etc.->Click Add Category->Select Categories->Save Member with their categories. We would then be able to generate collections of staff based on different category criteria. Do I need to break it out into two separate CMPs, one to add the new staff and one to connect staff to categories?

Thanks.]]>
khansen Mar 03, 2015, 03:40 PM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-521772
<![CDATA[Re: Help with simple many-to-many nested migxdb CMP]]> https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-521767 in the MIGXdb - Settings - field 'Hook Snippets':

{"aftersave":"staff_member_categories_aftersave"}


and add this snippet with name 'staff_member_categories_aftersave' and code:

<?php

$object = & $modx->getOption('object',$scriptProperties,null);
$properties = $modx->getOption('scriptProperties',$scriptProperties,array());
$postvalues = $modx->getOption('postvalues',$scriptProperties,array());

$co_id = $modx->getOption('co_id',$properties,0);

$configs = $modx->getOption('configs', $properties, '');

if ($object){
    $object->set('staff_id',$co_id);    
    $object->save();
}

return '';
]]>
Bruno17 Mar 03, 2015, 02:27 PM https://forums.modx.com/thread/96409/help-with-simple-many-to-many-nested-migxdb-cmp#dis-post-521767