You are here

public static function CodeMirrorPluginTrait::setButtonsValue in The CodeMirror Editor 8

Value callback for CodeMirror buttons.

Prevent buttons from being stored in config with keyed values.

Parameters

array $element: An associative array containing the properties of the element.

mixed $input: The incoming input to populate the form element. If this is FALSE, the element's default value should be returned.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

mixed The value to assign to the element.

File

src/CodeMirrorPluginTrait.php, line 200

Class

CodeMirrorPluginTrait
Provides a helper methods to for CodeMirror plugins.

Namespace

Drupal\codemirror_editor

Code

public static function setButtonsValue(array &$element, $input, FormStateInterface $form_state) {
  if ($input === FALSE) {
    return $element['#default_value'] ?? [];
  }
  return $input;
}