How to get bundle in form alter? I want bundle in hook_form_alter. In Drupal7 we can get all these in hook_form_alter.

I tried like this in D7:

function MYMODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  $bundle_type = $form['#bundle'];
}


Here I am getting bundle in D7.
Whereas in D8 I am not getting any bundle like article/page/tags etc.,
This is the final solution:

use Drupal\Core\Entity\ContentEntityForm;

$bundle = FALSE;
$form_object = $form_state-&gt;getFormObject();
if ($form_object instanceof ContentEntityForm) {
  $bundle = $form_object-&gt;getEntity()-&gt;bundle();
}