<?php
form['entity_browser'] = [
'#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' => 'experience_cms_entity_browser',
//'#cardinality' => 1,
//'#selection_mode' => 'selection_edit',
//'#default_value' => [],
'#entity_browser_validators' => [
'entity_type' => [
'type' => 'node',
],
],
'#custom_hidden_id' => 'edit-content-link-target-id',
'#process' => [
[
'\Drupal\entity_browser\Element\EntityBrowserElement',
'processEntityBrowser',
],
[
'Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget',
'processEntityBrowser',
],
]
],
'current' => [
'#theme_wrappers' => ['container'],
'#attributes' => [
'class' => 'entities-list',
],
'items' => [],
],
'#after_build' => [
[
'Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget',
'afterBuild',
],
],
'#attached' => [
'library' => [
'entity_browser/entity_reference',
],
],
],
];
?>
OR easy one
<?php
form['entity_browser'] = [
'#type' => 'container',
'#id' => 'edit-content-link-wrapper',
'#attributes' => [
'id' => 'edit-content-link-wrapper',
],
'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-wrapper',
'event' => 'entity_browser_value_updated',
],
],
'entity_browser' => [
'#type' => 'entity_browser',
'#entity_browser' => 'experience_cms_entity_browser',
'#entity_browser_validators' => [
'entity_type' => [
'type' => 'node',
],
],
'#custom_hidden_id' => 'edit-content-link-target-id',
'#process' => [
[
'\Drupal\entity_browser\Element\EntityBrowserElement',
'processEntityBrowser',
],
[
'Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget',
'processEntityBrowser',
],
]
],
];
Comments
Post a Comment