function tripal_bulk_loader_delete_field
2.x tripal_bulk_loader.DEPRECATED.inc | tripal_bulk_loader_delete_field($priority, $delete_field_index, $template_array) |
3.x tripal_bulk_loader.DEPRECATED.inc | tripal_bulk_loader_delete_field($priority, $delete_field_index, $template_array) |
1.x tripal_bulk_loader.api.templates.inc | tripal_bulk_loader_delete_field($priority, $delete_field_index, $template_array) |
An API function to delete a field from a template array
Parameters
$priority: The priority of the record containing the field
$delete_field_index: The index of the field to be deleted
$template_array: The array describing the template
Return value
The modified template array
Related topics
1 call to tripal_bulk_loader_delete_field()
- tripal_bulk_loader_modify_template_base_form_submit in tripal_bulk_loader/
includes/ tripal_bulk_loader.admin.templates.inc - Submit for tripal_bulk_loader_modify_template_base_form
File
- tripal_bulk_loader/
api/ tripal_bulk_loader.api.templates.inc, line 108 - All functions in this file provide an API to administrative management of bulk loader templates
Code
function tripal_bulk_loader_delete_field($priority, $delete_field_index, $template_array) {
if (empty($template_array)) {
drupal_set_message("Unable to delete record with a priority of $priority since the template was not supplied", 'error');
return FALSE;
}
// Re-order the remaining fields of the same record to ensure that the indicies are
// 0 to size and. If this is not done, weird behaviour may result
$new_template_array = $template_array;
$new_template_array[$priority]['fields'] = array();
$i = 0;
foreach ($template_array[$priority]['fields'] as $field_index => $field_details) {
if ($field_index != $delete_field_index) {
$new_template_array[$priority]['fields'][$i] = $field_details;
$i++;
}
}
// If this field was the only one in the current record, also delete the record
if (empty($new_template_array[$priority]['fields'])) {
$new_template_array = tripal_bulk_loader_delete_record($priority, $new_template_array);
}
return $new_template_array;
}