Hi all
I'm trying to get related data from two tables and output it into a TableListField which can then use the LightWindow to show more detailed information about rows and allow easy editing of them.
I've been trawling through the documentation for the last couple of hours and I can't find anything useful in there. The TableListField article is promising, but its JOIN parameter is empty >_<
Can anyone give me a hand, please?
public function showCaseTable() {
$resultSet = new DataObjectSet();
$filter = '';
$sort = "CaseTracker.ID ASC";
$join = 'LEFT JOIN CaseTrackerStatus ON CaseTracker.Status = CaseTrackerStatus.ID';
$instance = singleton('CaseTracker');
$query = $instance->buildSQL($filter, $sort, null, $join);
$query->groupby[] = 'CaseTracker.ID';
$trackerTable = new TableListField(
'TrackerTable',
'CaseTracker',
array(
'ID' => 'ID',
'CaseName' => 'Name',
'LastEdited' => 'Last updated',
'CaseStatus' => 'Status'
)
);
$trackerTable->setFieldCasting(array(
'LastEdited' => 'Date->Nice'
));
$trackerTable->setPermissions(array(
'export',
'delete',
'print'
));
// Generate fieldsets
$fields = new FieldSet(
new HiddenField('ID', 'ID'),
$trackerTable
);
$actions = new FieldSet(
new FormAction('save', 'Update Cases')
);
return new Form($this, "EditForm", $fields, $actions);
}