Hi Bruno,
Sorry for the delay.
So here it is.
Database schema:
<?xml version="1.0" encoding="UTF-8"?>
<model package="inscricoes_online" baseClass="xPDOObject" platform="mysql" defaultEngine="InnoDB" phpdoc-package="inscricoes_online" version="1.1">
<object class="InscricoesCttDistritos" table="ctt_distritos" extends="xPDOSimpleObject">
<field key="DD" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="DESIG" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="pos" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<composite alias="Concelhos" class="InscricoesCttConcelhos" local="DD" foreign="DD" cardinality="many" owner="local" />
<index alias="DD" name="DD" primary="false" unique="false" type="BTREE">
<column key="DD" length="" collation="A" null="false" />
</index>
<index alias="DESIG" name="DESIG" primary="false" unique="false" type="BTREE">
<column key="DESIG" length="" collation="A" null="false" />
</index>
</object>
<object class="InscricoesCttConcelhos" table="ctt_concelhos" extends="xPDOSimpleObject">
<field key="DD" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="CC" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="DESIG" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="pos" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="DistritoDoConcelho" class="InscricoesCttDistritos" local="DD" foreign="DD" cardinality="one" owner="foreign" />
<composite alias="CodigosPostais" class="InscricoesCttCodigosPostais" local="CC" foreign="CC" cardinality="many" owner="local" />
<index alias="DD" name="DD" primary="false" unique="false" type="BTREE">
<column key="DD" length="" collation="A" null="false" />
</index>
<index alias="CC" name="CC" primary="false" unique="false" type="BTREE">
<column key="CC" length="" collation="A" null="false" />
</index>
<index alias="DESIG" name="DESIG" primary="false" unique="false" type="BTREE">
<column key="DESIG" length="" collation="A" null="false" />
</index>
</object>
<object class="InscricoesCttCodigosPostais" table="ctt_codigos_postais" extends="xPDOSimpleObject">
<field key="DD" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="CC" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="LLLL" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="LOCALIDADE" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="ART_COD" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="ART_TIPO" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="PRI_PREP" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="ART_TITULO" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="SEG_PREP" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="ART_DESIG" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="ART_LOCAL" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="TROÇO" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="PORTA" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="CLIENTE" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="CP4" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="CP3" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="CPALF" dbtype="varchar" precision="255" phptype="string" null="false" default="" />
<field key="pos" dbtype="int" precision="11" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="Distrito" class="InscricoesCttDistritos" local="DD" foreign="DD" cardinality="one" owner="foreign" />
<aggregate alias="Concelho" class="InscricoesCttConcelhos" local="CC" foreign="CC" cardinality="one" owner="foreign" />
<index alias="DD" name="DD" primary="false" unique="false" type="BTREE">
<column key="DD" length="" collation="A" null="false" />
</index>
<index alias="CC" name="CC" primary="false" unique="false" type="BTREE">
<column key="CC" length="" collation="A" null="false" />
</index>
<index alias="CP4" name="CP4" primary="false" unique="false" type="BTREE">
<column key="CP4" length="" collation="A" null="false" />
</index>
<index alias="CP3" name="CP3" primary="false" unique="false" type="BTREE">
<column key="CP3" length="" collation="A" null="false" />
</index>
</object>
</model>
Config file for Districts:
{
"formtabs":[
{
"MIGX_id":2005,
"caption":"CTT - Districts",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":11987,
"field":"DD",
"caption":"District code *",
"description":"Mandatory - District Code",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"text",
"validation":"required",
"configs":{
"allowBlank":"false",
"maxLength":255,
"minLength":1,
"regex":"",
"regexText":""
},
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":1
},
{
"MIGX_id":11988,
"field":"DESIG",
"caption":"Designation *",
"description":"Mandatory - District Designation",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"text",
"validation":"required",
"configs":{
"allowBlank":"false",
"maxLength":255,
"minLength":1,
"regex":"",
"regexText":""
},
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":2
},
{
"MIGX_id":11989,
"field":"published",
"caption":"Available *",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"listbox",
"validation":"",
"configs":{
"allowBlank":"false",
"listWidth":"",
"title":"",
"typeAhead":"false",
"typeAheadDelay":250,
"listEmptyText":"",
"stackItems":true
},
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"No==0||Yes==1",
"default":1,
"useDefaultIfEmpty":1,
"pos":3
},
{
"MIGX_id":11990,
"field":"deleted",
"caption":"deleted",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"none",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"0",
"useDefaultIfEmpty":1,
"pos":4
}
],
"pos":1
}
],
"contextmenus":"update||duplicate||publish||unpublish||recall_remove_delete",
"actionbuttons":"addItem||toggletrash||exportview||resetwinposition",
"columnbuttons":"",
"filters":"",
"extended":{
"migx_add":"Add District",
"disable_add_item":"",
"add_items_directly":"",
"formcaption":"District - [[+DESIG]]",
"update_win_title":"Manage Districts",
"win_id":"ctt_distritos",
"maxRecords":"",
"addNewItemAt":"bottom",
"media_source_id":"",
"multiple_formtabs":"",
"multiple_formtabs_label":"",
"multiple_formtabs_field":"",
"multiple_formtabs_optionstext":"",
"multiple_formtabs_optionsvalue":"",
"actionbuttonsperrow":5,
"winbuttonslist":"cancel||done",
"extrahandlers":"this.resetWinPosition||this.update||this.handleColumnSwitch||this.csvExport",
"filtersperrow":4,
"packageName":"inscricoes",
"classname":"InscricoesCttDistritos",
"task":"",
"getlistsort":"pos",
"getlistsortdir":"ASC",
"sortconfig":"",
"gridpagesize":50,
"use_custom_prefix":"0",
"prefix":"",
"grid":"dragdrop",
"gridload_mode":2,
"check_resid":1,
"check_resid_TV":"",
"join_alias":"",
"has_jointable":"yes",
"getlistwhere":"",
"joins":"",
"hooksnippets":"",
"cmpmaincaption":"CTT - Postal Codes",
"cmptabcaption":"Districts",
"cmptabdescription":"Manage Districts",
"cmptabcontroller":"ctt_distritos",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"columns":[
{
"MIGX_id":2,
"header":"ID",
"dataIndex":"id",
"width":25,
"sortable":true,
"show_in_grid":0,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":3,
"header":"District Code",
"dataIndex":"DD",
"width":"",
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":4,
"header":"Designation",
"dataIndex":"DESIG",
"width":"",
"sortable":1,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":10,
"header":"Position",
"dataIndex":"pos",
"width":30,
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":7,
"header":"Published",
"dataIndex":"published",
"width":45,
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"this.renderSwitchStatusOptions",
"clickaction":"switchOption",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":[
{
"MIGX_id":1,
"name":"unpublished",
"use_as_fallback":1,
"value":"0",
"clickaction":"switchOption",
"handler":"",
"image":"assets\/components\/migx\/style\/images\/cb_empty.png"
},
{
"MIGX_id":2,
"name":"published",
"use_as_fallback":"",
"value":1,
"clickaction":"switchOption",
"handler":"",
"image":"assets\/components\/migx\/style\/images\/cb_ticked.png"
},
{
"MIGX_id":3,
"name":"unpublished",
"use_as_fallback":"",
"value":"0",
"clickaction":"switchOption",
"handler":"",
"image":"assets\/components\/migx\/style\/images\/cb_empty.png"
}
],
"editor":""
},
{
"MIGX_id":8,
"header":"deleted",
"dataIndex":"deleted",
"width":"",
"sortable":true,
"show_in_grid":"0",
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
}
],
"category":""
}
Config for Counties:
{
"formtabs":[
{
"MIGX_id":2015,
"caption":"CTT - Counties",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":12120,
"field":"CC",
"caption":"County Code *",
"description":"Mandatory - County Code",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"text",
"validation":"required",
"configs":{
"allowBlank":"false",
"maxLength":255,
"minLength":1,
"regex":"",
"regexText":""
},
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":1
},
{
"MIGX_id":12121,
"field":"DD",
"caption":"District *",
"description":"Mandatory - Linked District Code",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"listbox",
"validation":"required",
"configs":{
"allowBlank":true,
"listWidth":"",
"title":"",
"typeAhead":"false",
"typeAheadDelay":250,
"listEmptyText":"",
"stackItems":"false"
},
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"@SELECT '' AS `name` ,'' AS `id` UNION ALL (SELECT `DESIG` AS `name`,`DD` as `id` FROM `[[+PREFIX]]ctt_distritos` WHERE `published` = 1 and `deleted` = 0)",
"default":"",
"useDefaultIfEmpty":"0",
"pos":2
},
{
"MIGX_id":12122,
"field":"DESIG",
"caption":"Designation *",
"description":"Mandatory - District Designation",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"text",
"validation":"required",
"configs":{
"allowBlank":"false",
"maxLength":255,
"minLength":1,
"regex":"",
"regexText":""
},
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":3
},
{
"MIGX_id":12123,
"field":"published",
"caption":"Published *",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"listbox",
"validation":"",
"configs":{
"allowBlank":"false",
"listWidth":"",
"title":"",
"typeAhead":"false",
"typeAheadDelay":250,
"listEmptyText":"",
"stackItems":true
},
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"No==0||Yes==1",
"default":1,
"useDefaultIfEmpty":1,
"pos":4
},
{
"MIGX_id":12124,
"field":"deleted",
"caption":"deleted",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"none",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"0",
"useDefaultIfEmpty":1,
"pos":5
}
],
"pos":1
}
],
"contextmenus":"update||duplicate||publish||unpublish||recall_remove_delete",
"actionbuttons":"addItem||toggletrash||exportview||resetwinposition",
"columnbuttons":"",
"filters":[
{
"MIGX_id":1,
"name":"ctt_concelho_filter_distrito",
"label":"District",
"emptytext":"-- Filter District --",
"type":"combobox",
"getlistwhere":{
"DD":"[[+ctt_concelho_filter_distrito]]"
},
"getcomboprocessor":"getcombo",
"combotextfield":"DESIG",
"comboidfield":"DD",
"combowhere":"published=1 AND deleted=0",
"comboclassname":"InscricoesCttDistritos",
"combopackagename":"inscricoes",
"combo_use_custom_prefix":"0",
"comboprefix":"",
"combojoins":"",
"comboparent":"",
"default":"all"
}
],
"extended":{
"migx_add":"Add County",
"disable_add_item":"",
"add_items_directly":"",
"formcaption":"County - [[+DESIG]]",
"update_win_title":"Manage Counties",
"win_id":"ctt_concelhos",
"maxRecords":"",
"addNewItemAt":"bottom",
"media_source_id":"",
"multiple_formtabs":"",
"multiple_formtabs_label":"",
"multiple_formtabs_field":"",
"multiple_formtabs_optionstext":"",
"multiple_formtabs_optionsvalue":"",
"actionbuttonsperrow":5,
"winbuttonslist":"cancel||done",
"extrahandlers":"this.resetWinPosition||this.update||this.handleColumnSwitch||this.csvExport",
"filtersperrow":4,
"packageName":"inscricoes",
"classname":"InscricoesCttConcelhos",
"task":"",
"getlistsort":"pos",
"getlistsortdir":"ASC",
"sortconfig":"",
"gridpagesize":50,
"use_custom_prefix":"0",
"prefix":"",
"grid":"dragdrop",
"gridload_mode":2,
"check_resid":1,
"check_resid_TV":"",
"join_alias":"",
"has_jointable":"yes",
"getlistwhere":"",
"joins":"",
"hooksnippets":"",
"cmpmaincaption":"CTT - Postal Codes",
"cmptabcaption":"Counties",
"cmptabdescription":"Manage Counties",
"cmptabcontroller":"ctt_concelhos",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"columns":[
{
"MIGX_id":2,
"header":"ID",
"dataIndex":"id",
"width":25,
"sortable":true,
"show_in_grid":0,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":3,
"header":"District",
"dataIndex":"DD",
"width":"",
"sortable":1,
"show_in_grid":1,
"customrenderer":"",
"renderer":"this.renderChunk",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"[[migxLoopCollection?\n&packageName=`inscricoes`\n&classname=`InscricoesCttConcelhos`\n&joins=`[{\"alias\":\"DistritoDoConcelho\"}]`\n&where=`{\"id\":\"[[+id]]\"}`\n&tpl=`@CODE:[[+DistritoDoConcelho_DESIG]]`\n&outputSeparator=``\n&debug=`0`]]",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":4,
"header":"County Code",
"dataIndex":"CC",
"width":"",
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":5,
"header":"Designation",
"dataIndex":"DESIG",
"width":"",
"sortable":1,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":6,
"header":"Position",
"dataIndex":"pos",
"width":30,
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":7,
"header":"Published",
"dataIndex":"published",
"width":45,
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"this.renderSwitchStatusOptions",
"clickaction":"switchOption",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":[
{
"MIGX_id":1,
"name":"unpublished",
"use_as_fallback":1,
"value":"0",
"clickaction":"switchOption",
"handler":"",
"image":"assets\/components\/migx\/style\/images\/cb_empty.png"
},
{
"MIGX_id":2,
"name":"published",
"use_as_fallback":"",
"value":1,
"clickaction":"switchOption",
"handler":"",
"image":"assets\/components\/migx\/style\/images\/cb_ticked.png"
},
{
"MIGX_id":3,
"name":"unpublished",
"use_as_fallback":"",
"value":"0",
"clickaction":"switchOption",
"handler":"",
"image":"assets\/components\/migx\/style\/images\/cb_empty.png"
}
],
"editor":""
},
{
"MIGX_id":8,
"header":"deleted",
"dataIndex":"deleted",
"width":"",
"sortable":true,
"show_in_grid":"0",
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
}
],
"category":""
}