function uc_extra_fields_pane_preprocess_table in Extra Fields Checkout Pane 7
Alters the uc_store_address_fields_form table.
Adds a column "Action" and action links for each Extra Fields Pane address field.
See also
uc_extra_fields_pane_form_uc_store_address_fields_form_alter()
File
- ./
uc_extra_fields_pane.module, line 496 - Module: uc_extra_fields_pane.module
Code
function uc_extra_fields_pane_preprocess_table(&$variables) {
// Make sure we altering the right table.
if (!empty($variables['attributes']['id']) && $variables['attributes']['id'] == 'uc-store-address-fields-weight-table') {
$fields = UCXF_FieldList::getFieldsFromPane(array(
'extra_delivery',
'extra_billing',
));
// Add column "Action" to the table.
$variables['header'][] = t('Action');
// For each field, add the action value.
foreach ($variables['rows'] as $key => $row) {
$fieldname = $row['data'][0];
$actions = '';
if (isset($fields[$fieldname])) {
$field = $fields[$fieldname];
// Add action links.
$links = array();
if (uc_extra_fields_pane_access($field, 'edit')) {
$links['edit'] = l(t('edit'), 'admin/store/settings/countries/fields/' . $field->field_id . '/edit');
}
if (uc_extra_fields_pane_access($field, 'delete')) {
$links['delete'] = l(t('delete'), 'admin/store/settings/countries/fields/' . $field->field_id . '/delete');
}
if (count($links) > 0) {
$actions = implode(' | ', $links);
}
}
$variables['rows'][$key]['data'][] = $actions;
}
}
}