function options_field_update_forbid

Implements hook_field_update_forbid().

File

drupal/core/modules/field/modules/options/options.module, line 372
Defines selection, check box and radio button widgets for text and numeric fields.

Code

function options_field_update_forbid($field, $prior_field, $has_data) {
  if ($field['module'] == 'options' && $has_data) {

    // Forbid any update that removes allowed values with actual data.
    $lost_keys = array_diff(array_keys($prior_field['settings']['allowed_values']), array_keys($field['settings']['allowed_values']));
    if (_options_values_in_use($field, $lost_keys)) {
      throw new FieldUpdateForbiddenException(t('A list field (@field_name) with existing data cannot have its keys changed.', array(
        '@field_name' => $field['field_name'],
      )));
    }
  }
}