I have a new issue that is most likely an overlooked setting but I can't quite figure it out.
I am nesting a migxdb grid that links to an "Images" table from the parent "Products" table. Essentially, I need the id from the parent product to be recorded into the IMage record (one-to-many from Products to Images). I can get the image grid to display, but it is showing ALL records in the image table. Furthermore, when I add an image, it doesn't record the current product record id into the Images table.
Here is the Schema
<?xml version="1.0" encoding="UTF-8"?>
<model package="productcatalog" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="Catalog" table="prod_catalog" extends="xPDOSimpleObject" >
<field key="prodno" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="description" dbtype="text" phptype="string" />
<field key="classid" dbtype="text" phptype="string"/>
<field key="prodname" dbtype="text" phptype="string" null="false" default="" />
<field key="specifications" dbtype="text" phptype="json" null="false" default="" />
<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
<field key="createdon" dbtype="datetime" phptype="datetime" null="false" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
<column key="id" collation="A" null="false" />
</index>
<aggregate alias="Creator" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign" />
<aggregate alias="ProductCategory" class="ProdClass" local="classid" foreign="id" cardinality="one" owner="foreign" />
<composite alias="Images" class="ProdImg" local="id" foreign="prodid" cardinality="many" owner="local"/>
</object>
<object class="ProdImg" table="prod_images" extends="xPDOSimpleObject" >
<field key="description" dbtype="text" phptype="string" />
<field key="imgpath" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="prodid" dbtype="int" precision="50" phptype="integer" null="false" default="0" />
<field key="createdby" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
<field key="createdon" dbtype="datetime" phptype="datetime" null="false" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
<column key="id" collation="A" null="false" />
</index>
<aggregate alias="Creator" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign" />
<aggregate alias="Product" class="Catalog" local="prodid" foreign="id" cardinality="one" owner="foreign" />
</object>
<object class="ProdClass" table="prod_classes" extends="xPDOSimpleObject" >
<field key="classname" dbtype="varchar" precision="255" phptype="string" />
<field key="classimg" dbtype="text" phptype="string" />
<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
<column key="id" collation="A" null="false" />
</index>
</object>
</model>
and here is the config for the parent (Catalog) CMP:
{
"formtabs":[
{
"MIGX_id":1,
"caption":"General",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":1,
"field":"prodno",
"caption":"Product Number",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"text",
"configs":"",
"sourceFrom":"config",
"sources":"[]",
"inputOptionValues":"",
"default":""
},
{
"MIGX_id":2,
"field":"prodname",
"caption":"Product Name",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"text",
"configs":"",
"sourceFrom":"config",
"sources":"[]",
"inputOptionValues":"",
"default":""
},
{
"MIGX_id":4,
"field":"classid",
"caption":"Category",
"description":"",
"description_is_code":"0",
"inputTV":"ProductCategories",
"inputTVtype":"",
"configs":"",
"sourceFrom":"config",
"sources":"[]",
"inputOptionValues":"",
"default":""
},
{
"MIGX_id":3,
"field":"description",
"caption":"Description",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"richtext",
"configs":"",
"sourceFrom":"config",
"sources":"[]",
"inputOptionValues":"",
"default":""
}
]
},
{
"MIGX_id":2,
"caption":"Specifications",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":1,
"field":"specifications",
"caption":"Specifications",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"migx",
"configs":"productspecs",
"sourceFrom":"config",
"sources":"[]",
"inputOptionValues":"",
"default":""
}
]
},
{
"MIGX_id":3,
"caption":"Images",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":2,
"field":"images",
"caption":"",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"migxdb",
"configs":"ProductImages",
"sourceFrom":"config",
"sources":"[]",
"inputOptionValues":"",
"default":""
}
]
}
],
"contextmenus":"update||duplicate||activate||deactivate||recall_remove_delete||remove",
"actionbuttons":"addItem||bulk",
"columnbuttons":"",
"filters":"[]",
"extended":{
"migx_add":"",
"formcaption":"Manage the catalog products in the grid below",
"update_win_title":"Product Catalog",
"win_id":"productcatalog",
"maxRecords":"",
"addNewItemAt":"top",
"multiple_formtabs":"",
"extrahandlers":"",
"packageName":"productcatalog",
"classname":"Catalog",
"task":"",
"getlistsort":"",
"getlistsortdir":"",
"use_custom_prefix":"0",
"prefix":"",
"grid":"",
"gridload_mode":1,
"check_resid":1,
"check_resid_TV":"",
"join_alias":"",
"has_jointable":"yes",
"getlistwhere":"",
"joins":[
{
"classname":"ProdClass",
"alias":"ProductCategory",
"on":"ProductCategory.id=classid"
}
],
"cmpmaincaption":"Product Catalog",
"cmptabcaption":"Products",
"cmptabdescription":" ",
"cmptabcontroller":"",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"columns":[
{
"MIGX_id":1,
"header":"ID",
"dataIndex":"id",
"width":"",
"sortable":"false",
"show_in_grid":"0",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"[]"
},
{
"MIGX_id":2,
"header":"Product No",
"dataIndex":"prodno",
"width":50,
"sortable":true,
"show_in_grid":1,
"renderer":"",
"clickaction":"selectFromGrid",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"[]"
},
{
"MIGX_id":3,
"header":"Name",
"dataIndex":"prodname",
"width":500,
"sortable":true,
"show_in_grid":1,
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"[]"
},
{
"MIGX_id":4,
"header":"Classification",
"dataIndex":"ProductCategory_classname",
"width":"",
"sortable":true,
"show_in_grid":1,
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"[]"
}
]
}
and for the Images (ProdImg) CMP
{
"formtabs":[
{
"MIGX_id":1,
"caption":"Images",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":1,
"field":"imgpath",
"caption":"Image",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"image",
"configs":"",
"sourceFrom":"config",
"sources":"[]",
"inputOptionValues":"",
"default":""
}
]
}
],
"contextmenus":"update||recall_remove_delete||remove||remove_migx",
"actionbuttons":"addItem||bulk",
"columnbuttons":"update||deactivate||recall_remove_delete||remove||remove_migx",
"filters":"[]",
"extended":{
"migx_add":"Add Image",
"formcaption":"",
"update_win_title":"",
"win_id":"ProductImages",
"maxRecords":"",
"addNewItemAt":"top",
"multiple_formtabs":"",
"extrahandlers":"",
"packageName":"productcatalog",
"classname":"ProdImg",
"task":"",
"getlistsort":"",
"getlistsortdir":"",
"use_custom_prefix":"0",
"prefix":"",
"grid":"",
"gridload_mode":2,
"check_resid":1,
"check_resid_TV":"",
"join_alias":"",
"has_jointable":"yes",
"getlistwhere":"",
"joins":[
{
"alias":"Product"
}
],
"cmpmaincaption":"",
"cmptabcaption":"",
"cmptabdescription":"",
"cmptabcontroller":"",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"columns":[
{
"MIGX_id":1,
"header":"id",
"dataIndex":"id",
"width":"",
"sortable":"false",
"show_in_grid":"0",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"[]"
},
{
"MIGX_id":2,
"header":"Image",
"dataIndex":"imgpath",
"width":"",
"sortable":"false",
"show_in_grid":1,
"renderer":"this.renderImage",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"[]"
},
{
"MIGX_id":3,
"header":"prodid",
"dataIndex":"prodid",
"width":"",
"sortable":"false",
"show_in_grid":"0",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"[]"
}
]
}
Where am I missing a configuration to pull the current product id and put it in the Images table, as well as how do I build the where clause to only display grid results for the currently loaded product?