public function EntityBrowserBlock::blockForm in Entity Browser Block 8
Overrides \Drupal\Core\Block\BlockBase::blockForm().
Adds body and description fields to the block configuration form.
Overrides BlockPluginTrait::blockForm
File
- src/
Plugin/ Block/ EntityBrowserBlock.php, line 102
Class
- EntityBrowserBlock
- Defines a generic entity browser block type.
Namespace
Drupal\entity_browser_block\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
$form['selection'] = [
'#type' => 'container',
'#attributes' => [
'id' => 'entity-browser-block-form',
],
];
$form['selection']['entity_browser'] = [
'#type' => 'entity_browser',
'#entity_browser' => $this
->getDerivativeId(),
'#process' => [
[
'\\Drupal\\entity_browser\\Element\\EntityBrowserElement',
'processEntityBrowser',
],
[
self::class,
'processEntityBrowser',
],
],
'#default_value' => self::loadEntitiesByIDs($this->configuration['entity_ids']),
];
$order_class = 'entity-browser-block-delta-order';
$form['selection']['table'] = [
'#type' => 'table',
'#header' => [
$this
->t('Title'),
$this
->t('View mode'),
$this
->t('Operations'),
$this
->t('Order', [], [
'context' => 'Sort order',
]),
],
'#empty' => $this
->t('No entities yet'),
'#tabledrag' => [
[
'action' => 'order',
'relationship' => 'sibling',
'group' => $order_class,
],
],
'#process' => [
[
self::class,
'processTable',
],
],
'#default_view_modes' => $this->configuration['view_modes'],
];
return $form;
}