You are here

public function ScheduleForm::buildEntity in Backup and Migrate 8.4

Same name and namespace in other branches
  1. 5.0.x src/Form/ScheduleForm.php \Drupal\backup_migrate\Form\ScheduleForm::buildEntity()

Builds an updated entity object based upon the submitted form values.

For building the updated entity object the form's entity is cloned and the submitted form values are copied to entity properties. The form's entity remains unchanged.

Parameters

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

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

Return value

\Drupal\Core\Entity\EntityInterface An updated copy of the form's entity object.

Overrides EntityForm::buildEntity

See also

\Drupal\Core\Entity\EntityFormInterface::getEntity()

File

src/Form/ScheduleForm.php, line 113

Class

ScheduleForm
Class ScheduleForm.

Namespace

Drupal\backup_migrate\Form

Code

public function buildEntity(array $form, FormStateInterface $form_state) {

  // Save period.
  $type = Schedule::getPeriodType($form_state
    ->getValue('period_type'));
  $seconds = Schedule::periodToSeconds([
    'number' => $form_state
      ->getValue('period_number'),
    'type' => $type,
  ]);
  $form_state
    ->setValue('period', $seconds);
  return parent::buildEntity($form, $form_state);
}