Skip to content

Instantly share code, notes, and snippets.

@cgi-caesar
Created March 7, 2017 11:31
Show Gist options
  • Save cgi-caesar/dc0363c08150d0ae0dbade6e1c64f339 to your computer and use it in GitHub Desktop.
Save cgi-caesar/dc0363c08150d0ae0dbade6e1c64f339 to your computer and use it in GitHub Desktop.
aMember (site.php): How to add new columns to grids in admin interface
<?php
Am_Di::getInstance()->hook->add('gridProductInitGrid', function(Am_Event_Grid $e) {
$e->getGrid()->addField('comment', ___('Comment'));
$e->getGrid()->addField('start_date', ___('Start Date Calculation'))
->setGetFunction(function($record, $grid, $fieldname, $field){
$r = explode(',', $record->{$fieldname});
foreach ($r as $k => $v) {
if ($v == 'group' && $record->renewal_group) {
$r[$k] = sprintf('group (%s)', $record->renewal_group);
}
if ($v == 'fixed') {
$r[$k] = sprintf('fixed (%s)', $record->start_date_fixed);
}
}
return implode(', ', $r);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment