You are here

public function ModerationStateWidget::storeValue in Lightning Scheduler 8

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

src/Plugin/Field/FieldWidget/ModerationStateWidget.php, line 128

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;
  }
  assert(!empty($element['#entity_uuid']));
  $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 = $element['#entity_uuid'];
  $transition_storage[$uuid] = $decoded;
  $form_state
    ->setValue('transition_storage', $transition_storage);
}