You are here

public function ModerationStateWidget::storeValue in Lightning Workflow 8.2

Same name and namespace in other branches
  1. 8.3 modules/lightning_scheduler/src/Plugin/Field/FieldWidget/ModerationStateWidget.php \Drupal\lightning_scheduler\Plugin\Field\FieldWidget\ModerationStateWidget::storeValue()

Validation method that accesses the hidden input element, and stores its value in the form state.

Parameters

array $element: The hidden input.

\Drupal\Core\Form\FormStateInterface $form_state: The form state to update.

File

modules/lightning_scheduler/src/Plugin/Field/FieldWidget/ModerationStateWidget.php, line 193

Class

ModerationStateWidget
Scheduler extension of Content Moderation's widget.

Namespace

Drupal\lightning_scheduler\Plugin\Field\FieldWidget

Code

public function storeValue(array $element, FormStateInterface $form_state) {
  if ($form_state
    ->getErrors()) {
    return;
  }
  $decoded = Json::decode($element['#value']);
  assert(is_array($decoded));
  $transition_storage = $form_state
    ->getValue('transition_storage') ?: [];

  // Support multiple widgets on one form (e.g. Inline Entity Form).
  $uuid = $this->entity
    ->uuid();
  $transition_storage[$uuid] = $decoded;
  $form_state
    ->setValue('transition_storage', $transition_storage);
}