I’m unsure, however adding bucket_bucket_title
to the Columns does display the friendly bucket name I’m looking for, it’s just not a listbox so can’t be edited inline.
Adding rel_bucket_id
in the columns works except it initially displays the id
number. Double clicking reveals a listbox with the friendly bucket names (the column Cell Editor is set to this.listboxEditor
. Selecting a friendly bucket name updates the id
number to that of the corresponding friendly bucket name selected.
The Fields configuration to achieve this for rel_bucket_id
is
- Field (tab) > Input TV type = listbox
- Input Options (tab) > Input Option Values =
@EVAL return 'select==||'.$modx->runSnippet('migxLoopCollection',array('packageName'=>'buckets','classname'=>'bucket','tpl'=>'@CODE:[[+bucket_title]]==[[+id]]','outputSeparator'=>'||','sortConfig'=>'[{"sortby":"bucket_title"}]'));
While this works I don’t think it is best practice to use @EVAL
when the faqs
Package has the relationship defined with
<aggregate alias="bucket" class="bucket" local="rel_bucket_id" foreign="id" cardinality="one" owner="foreign" />
To give you the full detail…
faqs-schema is
<?xml version="1.0" encoding="UTF-8"?>
<model package="faqs" baseClass="xPDOObject" platform="mysql" defaultEngine="INNODB" version="1.1">
<!-- define faq object
- prefix tables with package name to group and separate them from modx core tables or tables created by other packages
-->
<object class="faq" table="migxdb_faqs" extends="xPDOSimpleObject" >
<!-- available fields
- note 'id' is created automatically
rel_bucket_id text # tv.listbox-multiple of related venue bucket name>id
faq_title varchar(75)
faq_content text
faq_featured text # embedded tv.listbox-multiple of feature areas eg. top 6 on experience detail page
-->
<!-- faq object elements -->
<field key="rel_bucket_id" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
<field key="faq_title" dbtype="varchar" precision="150" phptype="string" null="false" default="" />
<field key="faq_content" dbtype="text" phptype="string" null="false" default="" />
<field key="faq_featured" dbtype="text" phptype="string" null="false" default="" />
<!-- used by MIGX -->
<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" />
<field key="pos" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
<!-- good practice for tracking -->
<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="createdby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="editedon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<!-- track createdby and editedby -->
<aggregate alias="CreatedBy" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="EditedBy" class="modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/>
<!-- join the migxdb_faqs table to the migxdb_buckets table which is defined in the bucket class under the buckets package defined in buckets-schema.xml -->
<aggregate alias="bucket" class="bucket" local="rel_bucket_id" foreign="id" cardinality="one" owner="foreign" />
</object>
</model>
migxdb_faqs JSON is
{
"formtabs":[
{
"MIGX_id":12,
"caption":"FAQs",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":69,
"field":"rel_bucket_id",
"caption":"rel_bucket_id",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"listbox",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"@EVAL return 'select==||'.$modx->runSnippet('migxLoopCollection',array('packageName'=>'buckets','classname'=>'bucket','tpl'=>'@CODE:[[+bucket_title]]==[[+id]]','outputSeparator'=>'||','sortConfig'=>'[{\"sortby\":\"bucket_title\"}]'));",
"default":"",
"useDefaultIfEmpty":"0",
"pos":1
},
{
"MIGX_id":70,
"field":"bucket_bucket_title",
"caption":"Bucket Title (from bucket_bucket_title)",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"listbox",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":2
},
{
"MIGX_id":62,
"field":"faq_title",
"caption":"faq_title",
"pos":3
},
{
"MIGX_id":63,
"field":"faq_content",
"caption":"faq_content",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"richtext",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":4
},
{
"MIGX_id":64,
"field":"faq_featured",
"caption":"faq_featured",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"listbox-multiple",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"==||Experience Detail==experience||FAQs List==faqslist",
"default":"",
"useDefaultIfEmpty":"0",
"pos":5
},
{
"MIGX_id":65,
"field":"published",
"caption":"published",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"checkbox",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"yes==1",
"default":"",
"useDefaultIfEmpty":"0",
"pos":6
}
],
"pos":1
}
],
"contextmenus":"update||duplicate||publish||unpublish||remove",
"actionbuttons":"addItem",
"columnbuttons":"",
"filters":"",
"extended":{
"migx_add":"",
"disable_add_item":"",
"add_items_directly":"",
"formcaption":"",
"update_win_title":"",
"win_id":"",
"maxRecords":"",
"addNewItemAt":"bottom",
"media_source_id":"",
"multiple_formtabs":"",
"multiple_formtabs_label":"",
"multiple_formtabs_field":"",
"multiple_formtabs_optionstext":"",
"multiple_formtabs_optionsvalue":"",
"actionbuttonsperrow":4,
"winbuttonslist":"",
"extrahandlers":"",
"filtersperrow":4,
"packageName":"faqs",
"classname":"faq",
"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":[
{
"alias":"bucket"
}
],
"hooksnippets":"",
"cmpmaincaption":"FAQs Main Caption",
"cmptabcaption":"FAQs Tab Caption ",
"cmptabdescription":"FAQs Tab Description",
"cmptabcontroller":"",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"permissions":{
"apiaccess":"",
"view":"",
"list":"",
"save":"",
"create":"",
"remove":"",
"delete":"",
"publish":"",
"unpublish":"",
"viewdeleted":"",
"viewunpublished":""
},
"fieldpermissions":"",
"columns":[
{
"MIGX_id":6,
"dataIndex":"id",
"header":"id"
},
{
"MIGX_id":3,
"header":"faq_title",
"dataIndex":"faq_title",
"width":"",
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":"this.textEditor"
},
{
"MIGX_id":4,
"header":"published",
"dataIndex":"published",
"width":"",
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"this.renderClickCrossTick",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":8,
"header":"rel_bucket_id",
"dataIndex":"rel_bucket_id",
"width":"",
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":"this.listboxEditor"
},
{
"MIGX_id":9,
"header":"joined bucket title",
"dataIndex":"bucket_bucket_title",
"width":"",
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
}
],
"category":""
}
buckets-schema is
<?xml version="1.0" encoding="UTF-8"?>
<model package="buckets" baseClass="xPDOObject" platform="mysql" defaultEngine="INNODB" version="1.1">
<!-- define faq object
- prefix tables with package name to group and separate them from modx core tables or tables created by other packages
-->
<object class="bucket" table="migxdb_buckets" extends="xPDOSimpleObject" >
<!-- available fields
- note 'id' is created automatically
bucket_title varchar(75)
-->
<!-- event object elements -->
<field key="bucket_title" dbtype="varchar" precision="75" phptype="string" null="false" default="" />
<!-- used by MIGX -->
<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" />
<field key="pos" dbtype="int" precision="10" phptype="integer" null="false" default="0" />
<!-- good practice for tracking -->
<field key="createdon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="createdby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="editedon" dbtype="datetime" phptype="datetime" null="true"/>
<field key="editedby" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<!-- track createdby and editedby -->
<aggregate alias="CreatedBy" class="modUser" local="createdby" foreign="id" cardinality="one" owner="foreign"/>
<aggregate alias="EditedBy" class="modUser" local="editedby" foreign="id" cardinality="one" owner="foreign"/>
</object>
</model>
migxdb_buckets JSON is
{
"formtabs":[
{
"MIGX_id":13,
"caption":"Buckets",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":67,
"field":"bucket_title",
"caption":"bucket_title",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":1
}
],
"pos":1
}
],
"contextmenus":"update||duplicate||remove",
"actionbuttons":"addItem",
"columnbuttons":"",
"filters":"",
"extended":{
"migx_add":"",
"disable_add_item":"",
"add_items_directly":1,
"formcaption":"",
"update_win_title":"",
"win_id":"",
"maxRecords":"",
"addNewItemAt":"bottom",
"media_source_id":"",
"multiple_formtabs":"",
"multiple_formtabs_label":"",
"multiple_formtabs_field":"",
"multiple_formtabs_optionstext":"",
"multiple_formtabs_optionsvalue":"",
"actionbuttonsperrow":4,
"winbuttonslist":"",
"extrahandlers":"",
"filtersperrow":4,
"packageName":"buckets",
"classname":"bucket",
"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":"Bucket Management",
"cmptabcaption":"Buckets",
"cmptabdescription":"Bucket description",
"cmptabcontroller":"",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"permissions":{
"apiaccess":"",
"view":"",
"list":"",
"save":"",
"create":"",
"remove":"",
"delete":"",
"publish":"",
"unpublish":"",
"viewdeleted":"",
"viewunpublished":""
},
"fieldpermissions":"",
"columns":[
{
"MIGX_id":2,
"dataIndex":"id",
"header":"id"
},
{
"MIGX_id":3,
"header":"bucket_title",
"dataIndex":"bucket_title",
"width":"",
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":"this.textEditor"
},
{
"MIGX_id":5,
"header":"pos",
"dataIndex":"pos",
"width":"",
"sortable":true,
"show_in_grid":"0",
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
}
],
"category":""
}