function ConfigHandler::remove

Same name and namespace in other branches
  1. 8.9.x core/modules/views_ui/src/Form/Ajax/ConfigHandler.php \Drupal\views_ui\Form\Ajax\ConfigHandler::remove()
  2. 10 core/modules/views_ui/src/Form/Ajax/ConfigHandler.php \Drupal\views_ui\Form\Ajax\ConfigHandler::remove()
  3. 11.x core/modules/views_ui/src/Form/Ajax/ConfigHandler.php \Drupal\views_ui\Form\Ajax\ConfigHandler::remove()

Submit handler for removing an item from a view.

File

core/modules/views_ui/src/Form/Ajax/ConfigHandler.php, line 262

Class

ConfigHandler
Provides a form for configuring an item in the Views UI.

Namespace

Drupal\views_ui\Form\Ajax

Code

public function remove(&$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $type = $form_state->get('type');
    $id = $form_state->get('id');
    // Store the item back on the view
    [
        $was_defaulted,
        $is_defaulted,
    ] = $view->getOverrideValues($form, $form_state);
    $executable = $view->getExecutable();
    // If the display selection was changed toggle the override value.
    if ($was_defaulted != $is_defaulted) {
        $display =& $executable->displayHandlers
            ->get($display_id);
        $display->optionsOverride($form, $form_state);
    }
    $executable->removeHandler($display_id, $type, $id);
    // Write to cache
    $view->cacheSet();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.