Problem/Motivation

I want to place the form to create a new message before the private messages inbox instead of redirecting the user to a new page.

I created a new Block Plugin using the code below:

<?php

namespace Drupal\sandbox_core\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a block with a the Create Private Message form.
 *
 * @Block(
 *   id = "create_private_message_form_block",
 *   admin_label = @Translation("Create Private Message Form block"),
 * )
 */
class CreatePrivateMessageFormBlock extends BlockBase {
  /**
   * {@inheritdoc}
   */
  public function build() {
    $private_message = \Drupal::entityTypeManager()->getStorage('private_message')->create();

    return \Drupal::service('entity.form_builder')->getForm($private_message, 'add');
  }

}

I placed the block into the Content region via Block Layout interface.

However, the "To" field does not render the same style as when the form is rendered on a separate page.

How can I achieve the same behavior for the "To" field?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

carolpettirossi created an issue.