0

Trying to get the field_name being deleted when viewing a route like entity.field_config.user_field_delete_form.

Example path: /admin/config/people/accounts/fields/user.user.field_name/delete

Some Hooks I've tried:

  1. hook_preprocess_html()
  2. hook_preprocess_page()
  3. hook_preprocess_page_title()
  4. hook_preprocess_form_field_config_delete_form_alter()

But the best I have found is an argument [%label] => Field Label.

I have an array of field_names and want to check if the field_name being deleted matches one of the values.

The goal is to add a custom \Drupal::messenger()->addWanrning($warning);.

This would be altering an existing delete form/page.

1

Try with hook_form_alter something like

/**
 * Implements hook_form_alter().
 */
function MyModule_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if ($form_id == "field_config_delete_form"){
    $field = $form_state->getFormObject()->getEntity();
    \Drupal::messenger()->addWarning("You are going to delete field : " . $field->getName());
  }
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.