Entity browser widget in custom config form

by echo   Last Updated May 26, 2018 12:07 PM

I am able to render the entity browser button in custom configuration form. But, after selecting the image it does not get displayed in the form, has anyone integrated in custom form so far ?

$form['content_link'] = [
    '#type' => 'container',
    '#parents' => ['content_link_wrapper'],
    '#weight' => -3,
    'widget' => [
      '#title' => t('Content Link'),
      '#description' => t('The content to be linked in the menu.'),
      '#field_name' => 'content_link',
      '#field_parents' => [],
      '#required' => TRUE,
      '#parents' => ['content_link'],
      '#tree' => TRUE,
      '#id' => 'edit-content-link',
      '#type' => 'details',
      '#open' => TRUE,
      'target_id' => [
        '#type' => 'hidden',
        '#id' => 'edit-content-link-target-id',
        '#attributes' => [
          'id' => 'edit-content-link-target-id',
        ],
        '#default_value' => "",
        '#ajax' => [
          'callback' => [
            '\Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget',
            'updateWidgetCallback',
          ],
          'wrapper' => 'edit-content-link',
          'event' => 'entity_browser_value_updated',
        ],
      ],
      'entity_browser' => [
        '#type' => 'entity_browser',
        '#entity_browser' => 'image_browser_dropzonejs',
        '#cardinality' => 1,
        '#selection_mode' => 'selection_append',
        '#default_value' => [],
        '#custom_hidden_id' => 'edit-content-link-target-id',
        '#process' => [
          [
            '\Drupal\entity_browser\Element\EntityBrowserElement','processEntityBrowser'
          ],
        ],
      ],
      'current' => [
        '#theme_wrappers' => ['container'],
        '#attributes' => [
          'class' => 'entities-list',
        ],
        'items' => [],
      ],
      '#attached' => [
        'library' => [
          'entity_browser/entity_reference',
        ],
      ],
    ],
  ];

enter image description here enter image description here



Related Questions


File entity browser and sub-directories

Updated July 21, 2018 05:07 AM