optionsOverride example

// Determine whether the values the user entered are intended to apply to     // the current display or the default display.
    [$was_defaulted$is_defaulted$revert] = $this->getOverrideValues($form$form_state);

    // Based on the user's choice in the display dropdown, determine which display     // these changes apply to.     $display_id = $form_state->get('display_id');
    if ($revert) {
      // If it's revert just change the override and return.       $display = &$this->getExecutable()->displayHandlers->get($display_id);
      $display->optionsOverride($form$form_state);

      // Don't execute the normal submit handling but still store the changed view into cache.       $this->cacheSet();
      return;
    }
    elseif ($was_defaulted === $is_defaulted) {
      // We're not changing which display these form values apply to.       // Run the regular submit handler for this form.     }
    elseif ($was_defaulted && !$is_defaulted) {
      // We were using the default display's values, but we're now overriding
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();
  }

}
Home | Imprint | This part of the site doesn't use cookies.