OK I've made some progress...I decided to do it without a new table for the relationship, and I'm getting the relationships to rebuild successfully now. I created a new field in Documents called related_project_c, which is a relate type field.
Here's what I added to the Project/vardefs.php body:
Code:
'documents' =>
array(
'name' => 'documents',
'type' => 'link',
'relationship' => 'project_documents',
'module' => 'Documents',
'bean_name' => 'aDocument',
'source' => 'non-db',
'vname' => 'LBL_DOCUMENTS',
), I used this in the Relationships section of Project/vardefs.php:
Code:
,'project_documents' => array(
'lhs_module' => 'Project',
'lhs_table' => 'project',
'lhs_key' => 'id',
'rhs_module' => 'Documents',
'rhs_table' => 'documents',
'rhs_key' => 'related_project_c',
'relationship_type' => 'one-to-many',
),
I even got the Documents subpanel to show in the Projects detail view, but the relationship in vardefs was set with both lhs_key => id and rhs_key=> id, which of course didn't show any documents inside the subpanel. Here's the problem, when I set rhs_key to my new relate field related_project_c, I get this error displayed in the subpanel area:
Code:
Error running count query for Project List: Query Failed:( SELECT count(*) c FROM documents where ( documents.related_project_c= 'cb7df11f-04c4-8fa4-2a8f-47388b9d7129' AND documents.deleted=0) AND documents.deleted=0 )::MySQL error 1054:
I get this error regardless of the subpanel settings. Seems like it thinks related_project_c doesn't exist. Is there something else I need to rebuild?
Here's what I added to Project/metadata/subpaneldefs.php
Code:
'documents' => array(
'top_buttons' => array(
array('widget_class' => 'SubPanelTopCreateRevisionButton',popup_module => 'Documents'),
),
'order' => 10,
'sort_order' => 'desc',
'module' => 'Documents',
'subpanel_name' => 'default',
'title_key' => 'LBL_DOCUMENTS',
'get_subpanel_data' => 'documents',
'add_subpanel_data' => 'related_project_c',
'fill_in_additional_fields' =>true,
),
Bookmarks