You are here

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

Same name and namespace in other branches
  1. 8 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 557

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) {
  $selected_actions =& $form_state
    ->getValue([
    'options',
    'selected_actions',
  ]);
  $selected_actions = array_filter($selected_actions, function ($action_data) {
    return !empty($action_data['state']);
  });
  foreach ($selected_actions as $delta => &$item) {
    unset($item['state']);
    if (empty($item['preconfiguration']['label_override'])) {
      unset($item['preconfiguration']['label_override']);
    }
    if (empty($item['preconfiguration'])) {
      unset($item['preconfiguration']);
    }
  }
  parent::submitOptionsForm($form, $form_state);
}