1 field.api.php | hook_field_schema_alter(&$schema, $field) |
Allow modules to alter the schema for a field.
@since 1.26.4 Hook added.
Parameters
array $schema: The schema definition as returned by hook_field_schema().
array $field: The field definition.
See also
Related topics
File
- core/
modules/ field/ field.api.php, line 277 - Hooks provided by the Field module.
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');
}
}