You are here

public function EntityForm::submit in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 modules/entity_form/src/Plugin/EntityBrowser/Widget/EntityForm.php \Drupal\entity_browser_entity_form\Plugin\EntityBrowser\Widget\EntityForm::submit()

Submits form.

Parameters

array $element: Widget part of the form.

array $form: Form.

\Drupal\Core\Form\FormStateInterface $form_state: Form state object.

Overrides WidgetBase::submit

File

modules/entity_form/src/Plugin/EntityBrowser/Widget/EntityForm.php, line 134

Class

EntityForm
Provides entity form widget.

Namespace

Drupal\entity_browser_entity_form\Plugin\EntityBrowser\Widget

Code

public function submit(array &$element, array &$form, FormStateInterface $form_state) {
  if (!empty($form_state
    ->getTriggeringElement()['#eb_widget_main_submit'])) {
    $entities = $this
      ->prepareEntities($form, $form_state);
    array_walk($entities, function (EntityInterface $entity) {
      $entity
        ->save();
    });
    $this
      ->selectEntities($entities, $form_state);
  }
}