function merci_core_activate_field in MERCI (Manage Equipment Reservations, Checkout and Inventory) 7.3
Attempts to directly activate a field that was disabled due to its module being disabled.
The normal API function for updating fields, field_update_field(), will not work on disabled fields. As a workaround, this function directly updates the database, but it is up to the caller to clear the cache.
Parameters
$field_name: The name of the field to activate.
Return value
Boolean indicating whether or not the field was activated.
2 calls to merci_core_activate_field()
- merci_core_delete_field in merci_core/
merci_core.module - Enables and deletes the specified field.
- merci_core_delete_instance in merci_core/
merci_core.module - Deletes the specified instance and handles field cleanup manually in case the instance is of a disabled field.
File
- merci_core/
merci_core.module, line 393
Code
function merci_core_activate_field($field_name) {
// Set it to active via a query because field_update_field() does
// not work on inactive fields.
$updated = db_update('field_config')
->fields(array(
'active' => 1,
))
->condition('field_name', $field_name, '=')
->condition('deleted', 0, '=')
->execute();
return !empty($updated) ? TRUE : FALSE;
}