Relationship between custom modules - add field to relationship table and display in subpanel


I have created a many to many relationship between to two custom modules and I I’m trying to add a field (apply_date) to this relationship which shows in the subpanel.

Ideally I would like the subpanel edit button to take me to a view to edit this field rather than the record in the linked module just like this link discusses -

But I’m trying to start out by getting this custom relationship field to display data like in this link - my attempt at following this is as follows:

  1. Editing the \custom\metadata\module1_module2MetaData.php file creates the custom field:
5 => 
    array (
      'name' => 'apply_date',
      'type' => 'date',

2.Adding / Editing the \custom\modules\Module1\metadata\subpanels\default.php file creates the custom for the new field in the listview:

		'Module1_Module2_apply_date' => 
		  array (
		    'width' => '8%',
		    'sortable' => false,
		    'vname' => 'LBL_APPLY_DATE',
		    'default' => true,

I’m not sure the key to the above array has the correct name but I have tried variations involving the field name with and without relationship name

$relation = 'Module1_Module2;
$relation_field = $relation . 'apply_date';

$dictionary[$module_name]["fields"]["{$relation}_fields"] = array(
    'name' => "{$relation}_fields",
    'rname' => 'id',
    'relationship_fields' =>
        'id' => "{$relation}_id",
        'apply_date' => "{$relation}_{$relation_field}"
    'type' => 'relate',
    'link' => 'Module2',
    'link_type' => 'relationship_info',
    'join_link_name' => $relation,
    'source' => 'non-db',
    'Importable' => false,
    'duplicate_merge' => 'disabled',
    'studio' => array('listview' => false),
    //'join_name' => $relation.'_c',
    'join_primary' => false,

$dictionary[$module_name]["fields"]["{$relation}_id"] = array(
    'name' => "{$relation}_id",
    'type' => 'varchar',
    'source' => 'non-db',
    'source' => 'non-db',
    'vname' => 'LBL_TEST_ID',
    'studio' => array('listview' => false),

$dictionary[$module_name]["fields"]["{$relation}_{$relation_field}"] = array(
    'name' => "{$relation}_{$relation_field}",
    'type' => 'date',
    'source' => 'non-db',
    //'massupdate' => false,
    'vname' => 'LBL_TEST_APPLY',
//    'studio' => array('listview' => false),

This leaves me with the correct field in the db table, and a column in the subpanel with no data.

I have tried following instructions from several links but cannot get this going. Printing $list_data[‘query’] from include\listview\listview.php gives me the following query which I guess constructs the subpanel data but I’m not sure how to debug further from here:

(SELECT , , module1.date_modified , ' ' module1_module2_fields , ' ' module1_module2module2_idb , module1.assigned_user_id , 'module1_module2' panel_name FROM module1 INNER JOIN module1_module2_c ON AND module1_module2_c.module1_module2module2_idb='ba0ee2d9-8e58-f62c-841e-57dbabe60b5f' AND module1_module2_c.deleted=0 where module1.deleted=0) ORDER BY asc

Can anyone please offer some advice on how to proceed?


There were a few mistakes in the 3rd file above, I guess I can’t edit until it’s approved or something like that:

$relation_field = $relation . ‘_apply_date’;

‘apply_date’ => $relation_field

$dictionary[$module_name][“fields”][$relation_field] = array(
‘name’ => $relation_field,