function hook_field_schema_alter
Allow modules to alter the schema for a field.
Parameters
array $schema: The schema definition as returned by hook_field_schema().
array $field: The field definition.
See also
Related topics
1 function implements hook_field_schema_alter()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- field_test_schema_alter_field_schema_alter in modules/
field/ tests/ field_test_schema_alter.install - Implements hook_field_schema_alter().
File
-
modules/
field/ field.api.php, line 291
Code
function hook_field_schema_alter(&$schema, $field) {
if ($field['type'] == 'image') {
// Alter the length of a field.
$schema['columns']['alt']['length'] = 2048;
// Add an additional column of data.
$schema['columns']['additional_column'] = array(
'description' => "Additional column added to image field table.",
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
);
// Add an additional index.
$schema['indexes']['fid_additional_column'] = array(
'fid',
'additional_column',
);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.