function BlockAddController::blockAddConfigureForm

Same name and namespace in other branches
  1. 11.x core/modules/block/src/Controller/BlockAddController.php \Drupal\block\Controller\BlockAddController::blockAddConfigureForm()
  2. 10 core/modules/block/src/Controller/BlockAddController.php \Drupal\block\Controller\BlockAddController::blockAddConfigureForm()
  3. 9 core/modules/block/src/Controller/BlockAddController.php \Drupal\block\Controller\BlockAddController::blockAddConfigureForm()
  4. 8.9.x core/modules/block/src/Controller/BlockAddController.php \Drupal\block\Controller\BlockAddController::blockAddConfigureForm()

Build the block instance add form.

Attributes

#[Route(path: '/admin/structure/block/add/{plugin_id}/{theme}', name: 'block.admin_add', requirements: [ '_permission' => 'administer blocks', ], defaults: [ 'theme' => NULL, '_title' => new TranslatableMarkup('Configure block'), ])]

Parameters

string $plugin_id: The plugin ID for the block instance.

string $theme: The name of the theme for the block instance.

Return value

array The block instance edit form.

File

core/modules/block/src/Controller/BlockAddController.php, line 25

Class

BlockAddController
Controller for building the block instance add form.

Namespace

Drupal\block\Controller

Code

public function blockAddConfigureForm($plugin_id, $theme) {
  // Create a block entity.
  $entity = $this->entityTypeManager()
    ->getStorage('block')
    ->create([
    'plugin' => $plugin_id,
    'theme' => $theme,
  ]);
  return $this->entityFormBuilder()
    ->getForm($entity);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.