How to get node Bundle in hook_form_alter on field config form? Can you wonderful people help me out please? I am altering the field config form (content types &gt; plan &gt; manage fields &gt; edit field) and cannot seem to get the proper bundle out. Every time I call the bundle() function it returns the string "field_config". However the bundle is supposed to be "plan". Perhaps it's different because I am on the field config form, and not a node form?

Below is my code, the things I've tried and the field object showing the proper bundle. Does anyone know of another solution for me to get "plan" out?

&lt;?php

use Drupal\Core\Config\Entity\ThirdPartySettingsInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Entity\ContentEntityForm;

/**
 * Implements hook_form_alter().
 */
function rent_plan_custom_form_alter(&amp;$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
// print $form_id;

  switch ($form_id) {

    case 'field_config_edit_form':

        print $form['#title'];

        $field = $form_state-&gt;getFormObject()-&gt;getEntity();
        $field_name = $field-&gt;getName();  //returns correct field_plan_purpose

        //first try
        print $field-&gt;bundle(); //&lt;---THIS RETURNS "field_config"

        //second try
        $bundle = FALSE;
        if ($form_object = $form_state-&gt;getFormObject()) {
            if ($form_object instanceof Drupal\Core\Entity\ContentEntityForm) {
                $bundle = $form_object-&gt;getEntity()-&gt;bundle();
            } elseif ($form_object instanceof Drupal\field_ui\Form\FieldConfigEditForm) {
                $bundle = $form_object-&gt;getEntity()-&gt;bundle(); 
            }
            print $bundle; //&lt;---THIS RETURNS "field_config"
        }

        //Field Object Results Below
        print '&lt;pre&gt;';
        print_r($field);
        print '&lt;/pre&gt;';


    break;
  }
}


Results from print_r($field)

Drupal\field\Entity\FieldConfig Object
(
    [deleted:protected] =&gt; 
    [fieldStorage:protected] =&gt; Drupal\field\Entity\FieldStorageConfig Object
        (
            [id:protected] =&gt; node.field_plan_purpose
            [field_name:protected] =&gt; field_plan_purpose
            [entity_type:protected] =&gt; node
            [type:protected] =&gt; text_long
            [module:protected] =&gt; text
            [settings:protected] =&gt; Array

            ... lots of more stuff
        )

    [id:protected] =&gt; node.plan.field_plan_purpose
    [field_name:protected] =&gt; field_plan_purpose
    [field_type:protected] =&gt; text_long
    [entity_type:protected] =&gt; node
    [bundle:protected] =&gt; plan
    [label:protected] =&gt; Purpose
    [description:protected] =&gt; 
    [settings:protected] =&gt; Array
        (
        )

    ...lots more stuff
)
You're looking for FieldDefinitionInterface::getTargetBundle


  Gets the bundle the field is attached to.
  
  This method should not be confused with EntityInterface::bundle() (configurable fields are config entities, and thus implement both interfaces):
  
  
  FieldDefinitionInterface::getTargetBundle() answers "as a field, which bundle are you attached to?".
  EntityInterface::bundle() answers "as a (config) entity, what is your own bundle?" (not relevant in our case, the config entity types used to store the definitions of configurable fields do not have bundles).
  


e.g. 

$target_bundle = $field-&gt;getTargetBundle();