You are here

public function YamlForm::getState in YAML Form 8

Returns the stored value for a given key in the form's state.

Parameters

string $key: The key of the data to retrieve.

mixed $default: The default value to use if the key is not found.

Return value

mixed The stored value, or NULL if no value exists.

Overrides YamlFormInterface::getState

File

src/Entity/YamlForm.php, line 1453

Class

YamlForm
Defines the form entity.

Namespace

Drupal\yamlform\Entity

Code

public function getState($key, $default = NULL) {
  $namespace = 'yamlform.yamlform.' . $this
    ->id();
  $values = \Drupal::state()
    ->get($namespace, []);
  return isset($values[$key]) ? $values[$key] : $default;
}