You are here

protected function FormsStepsProgressStepAddForm::copyFormValuesToEntity in Forms Steps 8

Copies top-level form values to entity properties.

This form can only change values for a progress step, which is part of forms_steps.

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 progress step of the form.

Overrides EntityForm::copyFormValuesToEntity

File

src/Form/FormsStepsProgressStepAddForm.php, line 132

Class

FormsStepsProgressStepAddForm
Class FormsStepsProgressStepAddForm.

Namespace

Drupal\forms_steps\Form

Code

protected function copyFormValuesToEntity(EntityInterface $entity, array $form, FormStateInterface $form_state) {

  /** @var \Drupal\forms_steps\FormsStepsInterface $entity */
  $values = $form_state
    ->getValues();

  // This is fired twice so we have to check that the entity does not already
  // have the progress step.
  if (!$entity
    ->hasProgressStep($values['id'])) {
    $entity
      ->addProgressStep($values['id'], $values['label'], $values['routes'], $values['link'], $values['link_visibility']);
  }
}