You are here

function field_name_prefix_remove_form_field_ui_field_overview_form_remove_field_prefix in Remove field name prefix 8

Validate function to prevent adding the field_ prefix.

1 string reference to 'field_name_prefix_remove_form_field_ui_field_overview_form_remove_field_prefix'
field_name_prefix_remove_form_field_ui_field_storage_add_form_alter in ./field_name_prefix_remove.module
Implements hook_form_FORM_ID_alter(). For: field_ui_field_storage_add_form

File

./field_name_prefix_remove.module, line 23

Code

function field_name_prefix_remove_form_field_ui_field_overview_form_remove_field_prefix(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  $field_name = preg_replace('/^field_/', '', $form_state
    ->getValue('field_name'));
  $form_state
    ->setValue('field_name', $field_name);
}