public function Tabs::getForm in Entity Browser 8.2
Same name and namespace in other branches
- 8 src/Plugin/EntityBrowser/WidgetSelector/Tabs.php \Drupal\entity_browser\Plugin\EntityBrowser\WidgetSelector\Tabs::getForm()
Returns widget selector form.
Return value
array Form structure.
Overrides WidgetSelectorInterface::getForm
File
- src/
Plugin/ EntityBrowser/ WidgetSelector/ Tabs.php, line 22
Class
- Tabs
- Displays entity browser widgets as tabs.
Namespace
Drupal\entity_browser\Plugin\EntityBrowser\WidgetSelectorCode
public function getForm(array &$form = [], FormStateInterface &$form_state = NULL) {
$element = [];
/** @var \Drupal\entity_browser\EntityBrowserInterface $browser */
$browser = $form_state
->getFormObject()
->getEntityBrowser();
foreach ($this->widget_ids as $id => $label) {
$name = 'tab_selector_' . $id;
$element[$name] = [
'#type' => 'button',
'#attributes' => [
'class' => [
'tab',
],
],
'#value' => $label,
'#disabled' => $id == $this
->getDefaultWidget(),
'#executes_submit_callback' => TRUE,
'#limit_validation_errors' => [
[
$id,
],
],
// #limit_validation_errors only takes effect if #submit is present.
'#submit' => [],
'#name' => $name,
'#widget_id' => $id,
'#access' => $browser
->getWidget($id)
->access(),
];
}
$element['#attached']['library'][] = 'entity_browser/tabs';
return $element;
}