You are here

public function RegistrantsElementUtility::buildRegistrant in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/RegistrantsElementUtility.php \Drupal\rng\RegistrantsElementUtility::buildRegistrant()
  2. 3.x src/RegistrantsElementUtility.php \Drupal\rng\RegistrantsElementUtility::buildRegistrant()

Copies form values to registrant entity properties

Parameters

bool $validate: Optionally validate the form.

Return value

\Drupal\rng\RegistrantInterface A registrant entity with updated properties.

File

src/RegistrantsElementUtility.php, line 250

Class

RegistrantsElementUtility

Namespace

Drupal\rng

Code

public function buildRegistrant($validate = FALSE) {
  $value = $this->formState
    ->getTemporaryValue(array_merge([
    '_registrants_values',
  ], $this->element['#parents']));
  $this->formState
    ->setValue($this->element['#parents'], $value);
  $registrant = $this->formState
    ->get('registrant__entity');
  $display = $this->formState
    ->get('registrant__form_display');
  $registrant_tree = [
    'entities',
    'person',
    'registrant',
  ];
  $subform_registrant = NestedArray::getValue($this->element, $registrant_tree);
  $display
    ->extractFormValues($registrant, $subform_registrant, $this->formState);
  if ($validate) {
    $display
      ->validateFormValues($registrant, $subform_registrant, $this->formState);
  }
  return $registrant;
}