public function RegistrationRegistrantEditForm::buildForm in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/Form/RegistrationRegistrantEditForm.php \Drupal\rng\Form\RegistrationRegistrantEditForm::buildForm()
- 8 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 26
Class
- RegistrationRegistrantEditForm
- Configure registrant settings.
Namespace
Drupal\rng\FormCode
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
->toUrl();
$row[] = Link::fromTextAndUrl($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;
}