Entity Browser in Forms API I'm having trouble getting the entity browser widget to work correctly in a custom form. Just wondering if anyone has had any success in getting it working. I've got to the point the button is rendering, you can use the browser, select the media. The the media id is also attached to the hidden field the widget generates.

...from my digging around it looks like it never creates the right markup in the "current" div that get sent back from the ajax request that triggers on "process"

Code below...

      $form['entity_browser_wrapper'] = [
      '#type' =&gt; 'container',
      'widget' =&gt; [
          '#title' =&gt; t('Entity Browser'),
          '#field_name' =&gt; 'entity_browser_wrapper',
          '#field_parents' =&gt; [],
          '#required' =&gt; false,
          '#parents' =&gt; ['entity_browser_wrapper'],
          '#tree' =&gt; true,
          '#id' =&gt; 'edit-entity-browser-wrapper',
          '#type' =&gt; 'details',
          '#open' =&gt; true,
          'entity_browser' =&gt; [
              '#type' =&gt; 'entity_browser',
              '#entity_browser' =&gt; 'document_browser',
              '#cardinality' =&gt; 1,
              '#entity_browser_validators' =&gt; ['entity_type' =&gt; ['type' =&gt; 'media']],
              '#process' =&gt; [
                  ['\Drupal\entity_browser\Element\EntityBrowserElement', 'processEntityBrowser'],
                  ['\Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget', 'processEntityBrowser'],
              ]
          ],
          'current' =&gt; [
              '#theme_wrappers' =&gt; ['container'],
              '#attributes' =&gt; [
                  'class' =&gt; 'entities-list',
              ],
              'items' =&gt; [],
          ],
      ],
  ];


This is based off a question I found in the entity browser issues https://www.drupal.org/node/2816881. I've looked into the suggestions that were posted and have come up blank. 

Thanks
I got a possibly easier solution. you need to have entity_browser and entity_browser_block required as dependencies and installed in your module. Then in your BlockBase buildForm or LayoutDefault buildConfigurationForm you can do something like what they do in the entity_browser_block module in the EntityBrowserBlock.php
// make sure you have this at the top of your file
use Drupal\entity_browser_block\Plugin\Block\EntityBrowserBlock;

// blockForm or buildConfigurationForm
$test = EntityBrowserBlock::loadEntitiesByIDs(explode(' ',$configuration['selection']['entity_browser']['entity_ids']));
$form['selection'] = [
  '#type' =&gt; 'container',
  '#attributes' =&gt; ['id' =&gt; 'entity-browser-block-form'],
];
$form['selection']['entity_browser'] = [
  '#type' =&gt; 'entity_browser',
  '#entity_browser' =&gt; 'classes',
  '#process' =&gt; [
    [
      '\Drupal\entity_browser\Element\EntityBrowserElement',
      'processEntityBrowser',
    ],
    ['\Drupal\entity_browser_block\Plugin\Block\EntityBrowserBlock', 'processEntityBrowser'],
  ],
  '#default_value' =&gt; $test,
];

$order_class = 'entity-browser-block-delta-order';

$form['selection']['table'] = [
  '#type' =&gt; 'table',
  '#header' =&gt; [
    $this-&gt;t('Title'),
    $this-&gt;t('Operations'),
  ],
  '#empty' =&gt; $this-&gt;t('No entities yet'),
  '#tabledrag' =&gt; [
    [
      'action' =&gt; 'order',
      'relationship' =&gt; 'sibling',
      'group' =&gt; $order_class,
    ],
  ],
  '#process' =&gt; [
    ['\Drupal\entity_browser_block\Plugin\Block\EntityBrowserBlock', 'processTable'],
  ],
  '#default_view_modes' =&gt; 'default',
];