General entity browsing, selecting and creating tool. Works with any entity type. Can work with fields, WYSIWYG, custom forms, ...
Powerful, flexible, pluggable* and extensible.
*yes, it heavily relies on core plugin systemPart that decides which entities are "selected" on a given step. Can be:
interface WidgetInterface {
public function getForm(array &$original_form, FormStateInterface $form_state, array $aditional_widget_parameters);
public function validate(array &$form, FormStateInterface $form_state);
// Call WidgetBase::selectEntities() to propagate selection to the other parts
// of the entity browser (event).
public function submit(array &$element, array &$form, FormStateInterface $form_state);
}
Part that defines how switching between widgets work. Can be:
interface WidgetSelectorInterface {
public function getForm(array &$form, FormStateInterface &$form_state);
public function setDefaultWidget($widget);
public function validate(array &$form, FormStateInterface $form_state);
// Return UUID of the selected widget.
public function submit(array &$form, FormStateInterface $form_state);
}
Part that displays entities that are currently selected. Can be:
interface SelectionDisplayInterface {
public function getForm(array &$original_form, FormStateInterface $form_state);
public function validate(array &$form, FormStateInterface $form_state);
// Call SelectionDisplayBase::selectionDone() to finish "session" and return
// selected entities (event).
public function submit(array &$form, FormStateInterface $form_state);
}
Defines how entity browser appears in the broader context. Can be:
interface DisplayInterface {
// Some members ommitted for simplification ...
public function displayEntityBrowser(FormStateInterface $form_state);
public function selectionCompleted(array $entities);
// ...
}
// There is a form element. See \Drupal\entity_browser\Element\EntityBrowserElement
// for more info.
$form['entity_ids'] = [
'#type' => 'entity_browser',
'#entity_browser' => 'my_test_entity_browser',
'#cardinality' => 5,
];
Powerful entity reference widget, that allows creation/edit of referenced entities inline.
You can use Entity browser with its "Use existing" feature.
Very close to beta: fix critical bugs
Other things: UX, tests
You can use it!
(Lightning, Thunder, NP8 and many more do already.)
drupal.org/project/issues/entity_browser
github.com/drupal-media/entity_browser
#drupal-media on IRC, meeting every Wednesday 14:00 UTC
First Time Sprinter Workshop - 9:00-12:00 - Room Wicklow 2A
Mentored Core Sprint - 9:00-18:00 - Wicklow Hall 2B
General Sprints - 9:00 - 18:00 - Wicklow Hall 2A
Leave feedback: https//events.drupal.org/dublin2016/schedule