You are here

public function ViewsBulkOperationsBulkForm::submitOptionsForm in Views Bulk Operations (VBO) 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/field/ViewsBulkOperationsBulkForm.php \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm::submitOptionsForm()
  2. 8.2 src/Plugin/views/field/ViewsBulkOperationsBulkForm.php \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm::submitOptionsForm()
  3. 4.0.x src/Plugin/views/field/ViewsBulkOperationsBulkForm.php \Drupal\views_bulk_operations\Plugin\views\field\ViewsBulkOperationsBulkForm::submitOptionsForm()

Performs some cleanup tasks on the options array before saving it.

Overrides FieldPluginBase::submitOptionsForm

File

src/Plugin/views/field/ViewsBulkOperationsBulkForm.php, line 364

Class

ViewsBulkOperationsBulkForm
Defines the Views Bulk Operations field plugin.

Namespace

Drupal\views_bulk_operations\Plugin\views\field

Code

public function submitOptionsForm(&$form, FormStateInterface $form_state) {
  $options =& $form_state
    ->getValue('options');
  foreach ($options['selected_actions'] as $id => $action) {
    if (!empty($action['state'])) {
      if (isset($action['preconfiguration'])) {
        $options['preconfiguration'][$id] = $action['preconfiguration'];
        unset($options['selected_actions'][$id]['preconfiguration']);
      }
      $options['selected_actions'][$id] = $id;
    }
    else {
      unset($options['preconfiguration'][$id]);
      $options['selected_actions'][$id] = 0;
    }
  }
  parent::submitOptionsForm($form, $form_state);
}