I
I
Igor2017-07-28 07:23:44
Drupal
Igor, 2017-07-28 07:23:44

How to insert drupal8 registration form inside your block?

My block consists of 3 tabs. One of them is registration. How to display the registration form there?
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
afi13, 2017-07-28
@pingvin156

You can either get the login form from the formBuilder in your block's build() method, pass it to the template, and render where you want. See Drupal\user\Plugin\Block\UserLoginBlock for an example.
Or just render the 'user_login_block' inside your block like so:

$block_manager = \Drupal::service('plugin.manager.block');
$config = [];
$plugin_block = $block_manager->createInstance('system_breadcrumb_block', $config);
$access_result = $plugin_block->access(\Drupal::currentUser());
if (is_object($access_result) && $access_result->isForbidden() || is_bool($access_result) && !$access_result) {
  return [];
}
$render = $plugin_block->build();
return $render;

https://drupal.stackexchange.com/questions/171686/...
Better use DI instead of calling the \Drupal class

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question