public static function WidgetsConfig::submitAddWidget in Entity Browser 8
Same name and namespace in other branches
- 8.2 src/Form/WidgetsConfig.php \Drupal\entity_browser\Form\WidgetsConfig::submitAddWidget()
AJAX submit callback for adding widgets to the entity browser.
File
- src/
Form/ WidgetsConfig.php, line 173
Class
- WidgetsConfig
- Form for configuring widgets for entity browser.
Namespace
Drupal\entity_browser\FormCode
public static function submitAddWidget($form, FormStateInterface $form_state) {
$entity_browser = $form_state
->getFormObject()
->getEntity();
$widget = $form_state
->getValue('widget');
$weight = count($entity_browser
->getWidgets()) + 1;
$entity_browser
->addWidget([
'id' => $widget,
'label' => $widget,
'weight' => $weight,
// Configuration will be set on the widgets page.
'settings' => [],
]);
$form_state
->setRebuild();
}