You are here

protected function WorkflowTransitionEditForm::copyFormValuesToEntity in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/workflows/src/Form/WorkflowTransitionEditForm.php \Drupal\workflows\Form\WorkflowTransitionEditForm::copyFormValuesToEntity()

Copies top-level form values to entity properties

This form can only change values for a state, which is part of workflow.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the current form should operate upon.

array $form: A nested array of form elements comprising the form.

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

Overrides EntityForm::copyFormValuesToEntity

File

core/modules/workflows/src/Form/WorkflowTransitionEditForm.php, line 171

Class

WorkflowTransitionEditForm
Class WorkflowTransitionEditForm.

Namespace

Drupal\workflows\Form

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {
  if (!$form_state
    ->isValidationComplete()) {

    // Only do something once form validation is complete.
    return;
  }

  /** @var \Drupal\workflows\WorkflowInterface $entity */
  $values = $form_state
    ->getValues();
  $form_state
    ->set('created_transition', FALSE);
  $entity
    ->getTypePlugin()
    ->setTransitionLabel($values['id'], $values['label']);
  $entity
    ->getTypePlugin()
    ->setTransitionFromStates($values['id'], array_filter($values['from']));
}