W3cubDocs

/Drupal 8

public function FormState::setCached

public FormState::setCached($cache = TRUE)

Sets this form to be cached.

Parameters

bool $cache: TRUE if the form should be cached, FALSE otherwise.

Return value

$this

Throws

\LogicException If the current request is using an HTTP method that must not change state (e.g., GET).

Overrides FormStateInterface::setCached

File

core/lib/Drupal/Core/Form/FormState.php, line 497

Class

FormState
Stores information about the state of a form.

Namespace

Drupal\Core\Form

Code

public function setCached($cache = TRUE) {
  // Persisting $form_state is a side-effect disallowed during a "safe" HTTP
  // method.
  if ($cache && $this->isRequestMethodSafe()) {
    throw new \LogicException(sprintf('Form state caching on %s requests is not allowed.', $this->requestMethod));
  }

  $this->cache = (bool) $cache;
  return $this;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Form!FormState.php/function/FormState::setCached/8.1.x