You are here

public function RegistrationRegistrantEditForm::buildForm in RNG - Events and Registrations 8.2

Same name and namespace in other branches
  1. 8 src/Form/RegistrationRegistrantEditForm.php \Drupal\rng\Form\RegistrationRegistrantEditForm::buildForm()
  2. 3.x src/Form/RegistrationRegistrantEditForm.php \Drupal\rng\Form\RegistrationRegistrantEditForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

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

Return value

array The form structure.

Overrides EntityForm::buildForm

File

src/Form/RegistrationRegistrantEditForm.php, line 25

Class

RegistrationRegistrantEditForm
Configure registrant settings.

Namespace

Drupal\rng\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, RegistrationInterface $registration = NULL) {
  $form['#title'] = $this
    ->t('Edit identities', [
    '@label' => $registration
      ->label(),
  ]);
  $registrants = $registration
    ->getRegistrants();
  $rows = [];
  foreach ($registrants as $registrant) {
    $row = [];
    $row[] = $registrant
      ->id();
    $identity = $registrant
      ->getIdentity();
    if ($identity instanceof EntityInterface) {
      $url = $identity
        ->urlInfo();
      $row[] = $this
        ->l($identity
        ->label(), $url);
    }
    else {
      $row[] = $registrant
        ->label();
    }
    $rows[] = $row;
  }
  $form['registrants'] = [
    '#type' => 'table',
    '#header' => [
      $this
        ->t('Registrant ID'),
      $this
        ->t('Identity'),
    ],
    '#rows' => $rows,
    '#empty' => $this
      ->t('No identities associated with this registration.'),
  ];
  return $form;
}