atk4 / report

Reporting extension for Agile Data
https://agiletoolkit.org/
MIT License
3 stars 6 forks source link

UnionModel does not support getElement() #5

Closed DarkSide666 closed 7 years ago

DarkSide666 commented 7 years ago

For example,

// union model = purchase invoices + payments
$m = new \smbo\UnionModel($mi->persistence);
$m->addNestedModel($mi, [
    'dochead_id'    => '[dochead_id]',
    'date'          => '[date]',
    'contact'       => '[contact]',
]);
$m->addNestedModel($mp, [
    'dochead_id'    => '[id]',
    'date'          => '[date]',
    'contact'       => '[contact]',
]);

// THESE LINES BELOW WILL NOT WORK
$m->getElement('date')->caption = 'Document Date';
$m->getElement('contact')->caption = 'Supplier/Payee';
romaninsh commented 7 years ago

You need to addField them yourself. UnionModel will map them onto nested models, but you have to add them first.

DarkSide666 commented 7 years ago

OK this works:

$m->addField('date', ['caption' => 'Document Date', 'type' => 'date']);
$m->addField('contact', ['caption' => 'Supplier/Payee']);

Is this somewhere in docs? :)