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()->getDefinition("node"); $bundle_key = $definition->get('entity_keys')['bundle']; $values['entity_type'] = "node"; $values[$bundle_key] = "article"; $entity = Drupal::entityManager()->getStorage($definition->get('id')) ->create($values); return Drupal::service('entity.form_builder')->getForm($entity);
=> This example works well.
But if i replace entity type with comment and bundle with comment, not work :(.
$values = []; $definition = Drupal::entityManager()->getDefinition("comment"); $bundle_key = $definition->get('entity_keys')['bundle']; $values['entity_type'] = "comment"; $values[$bundle_key] = "comment"; $entity = Drupal::entityManager()->getStorage($definition->get('id')) ->create($values); return Drupal::service('entity.form_builder')->getForm($entity);