Hi all
I'm trying to select data for a query from two tables, and get it into a DataObject one way or another, so that it can then be used in a TableListField. I've spent a LOT of time trawling through documentation and code for the core files, and I can't get it to work.
I can do a DB::query to get the data, but then it's not in a DataObject, and it's not the best way of doing it, I know.
For views, do I need to create a DB table (like I do for proper tables) before it's queryable?
Any help would be much appreciated, it's driving me up the wall.
Thanks.
Current code:
# Either this
$CT = DataObject::Get('casetrackerview');
# Or this
$report = new TableListField(
'CorporateReport',
'CaseTracker',
array(
'ID' => 'ID'
)
);
# Is preferred for getting data, either way it needs to go into the TableListField
$report->setPermissions(array(
'export',
'delete',
'print'
));
$fields = new FieldSet(
new HiddenField('ID', 'ID'),
$report
);
$actions = new FieldSet();
return new Form($this, "EditForm", $fields, $actions);
DB Declarations:
class CaseTracker extends DataObject {
static $db = array(
'CaseName' => 'Varchar',
'DateBirth' => 'Date',
'TelNumber' => 'Int',
'Address' => 'Text',
'Postcode' => 'Varchar(8)'
);
static $has_one = array(
'Status' => 'CaseTrackerStatus'
);
class CaseTrackerStatus extends DataObject {
static $db = array(
'ShortText' => 'Varchar',
'AllText' => 'Varchar(100)',
'EmailData' => 'HTMLText'
);
static $has_many = array(
'Statuses' => 'CaseTracker'
);
}