public static function EntityBrowserFormTrait::processEntityBrowser in Helper 8
Render API callback: Processes the entity browser element.
File
- src/
EntityBrowserFormTrait.php, line 132
Class
- EntityBrowserFormTrait
- Provides helpers for adding an entity browser element to a form.
Namespace
Drupal\helperCode
public static function processEntityBrowser(&$element, FormStateInterface $form_state, &$complete_form) {
if (!is_array($element['#default_value'])) {
$element['#default_value'] = static::loadEntityBrowserEntitiesByIds($element['#default_value']);
}
$element = EntityBrowserElement::processEntityBrowser($element, $form_state, $complete_form);
$element['entity_ids']['#ajax'] = [
'callback' => [
self::class,
'updateEntityBrowserSelected',
],
'wrapper' => $element['#wrapper_id'],
'event' => 'entity_browser_value_updated',
];
$element['entity_ids']['#default_value'] = implode(' ', array_keys($element['#default_value']));
return $element;
}