You are here

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

Same name and namespace in other branches
  1. 8.2 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 24

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', array(
    '@label' => $registration
      ->label(),
  ));
  $registrants = $registration
    ->getRegistrants();
  $rows = array();
  foreach ($registrants as $registrant) {
    $row = array();
    $identity = $registrant
      ->getIdentity();
    if ($identity instanceof EntityInterface) {
      $url = $identity
        ->urlInfo();
      $row[] = $this
        ->l($identity
        ->label(), $url);
    }
    else {
      $row[] = t('<em>Deleted</em>');
    }
    $row[] = $registrant
      ->id();
    $rows[] = $row;
  }
  $form['registrants'] = array(
    '#type' => 'table',
    '#header' => array(
      $this
        ->t('Identity'),
      $this
        ->t('Registrant ID'),
    ),
    '#rows' => $rows,
    '#empty' => $this
      ->t('No identities associated with this registration.'),
  );
  return $form;
}