How can I load entity form for comment? I want to load entity form for comment entity type.

I can load entity form for node (entity type = node and bundle = article).

But the entity type = comment and bundle = comment.

Here is the code of loading entity:

  $values = [];
    $definition = \Drupal::entityManager()-&gt;getDefinition("node");
    $bundle_key = $definition-&gt;get('entity_keys')['bundle'];
    $values['entity_type'] = "node";
    $values[$bundle_key] = "article";
    $entity = \Drupal::entityManager()-&gt;getStorage($definition-&gt;get('id'))
      -&gt;create($values);
   return \Drupal::service('entity.form_builder')-&gt;getForm($entity);


=> This example works well.

But if i replace entity type with comment and bundle with comment, not work :(.

        $values = [];
        $definition = \Drupal::entityManager()-&gt;getDefinition("comment");
        $bundle_key = $definition-&gt;get('entity_keys')['bundle'];
        $values['entity_type'] = "comment";
        $values[$bundle_key] = "comment";
        $entity = \Drupal::entityManager()-&gt;getStorage($definition-&gt;get('id'))
          -&gt;create($values);
       return \Drupal::service('entity.form_builder')-&gt;getForm($entity);
it also needs the field name I think, check CommentDefaultFormatter::viewElements

https://api.drupal.org/api/drupal/core%21modules%21comment%21src%21Plugin%21Field%21FieldFormatter%21CommentDefaultFormatter.php/class/CommentDefaultFormatter/8

It uses a lazy builder so it can be built after render caching 

$output['comment_form'] = [ '#lazy_builder' => ['comment.lazy_builders:renderForm', [ $entity->getEntityTypeId(), $entity->id(), $field_name, $this->getFieldSetting('comment_type'), ]], '#create_placeholder' => TRUE, ];