function WorkflowStateEditForm::copyFormValuesToEntity

Same name in other branches
  1. 9 core/modules/workflows/src/Form/WorkflowStateEditForm.php \Drupal\workflows\Form\WorkflowStateEditForm::copyFormValuesToEntity()
  2. 8.9.x core/modules/workflows/src/Form/WorkflowStateEditForm.php \Drupal\workflows\Form\WorkflowStateEditForm::copyFormValuesToEntity()
  3. 10 core/modules/workflows/src/Form/WorkflowStateEditForm.php \Drupal\workflows\Form\WorkflowStateEditForm::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/WorkflowStateEditForm.php, line 163

Class

WorkflowStateEditForm
Entity form variant for editing workflow states.

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();
    $entity->getTypePlugin()
        ->setStateLabel($values['id'], $values['label']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.