public function RegistrantTypeForm::buildForm in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/Form/Entity/RegistrantTypeForm.php \Drupal\rng\Form\Entity\RegistrantTypeForm::buildForm()
- 8 src/Form/Entity/RegistrantTypeForm.php \Drupal\rng\Form\Entity\RegistrantTypeForm::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/ Entity/ RegistrantTypeForm.php, line 18
Class
- RegistrantTypeForm
- Form controller for Registrant types.
Namespace
Drupal\rng\Form\EntityCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$registrant_type = $this->entity;
if (!$registrant_type
->isNew()) {
$form['#title'] = $this
->t('Edit registrant type %label', [
'%label' => $registrant_type
->label(),
]);
}
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $registrant_type
->label(),
'#required' => TRUE,
];
$form['id'] = [
'#type' => 'machine_name',
'#title' => $this
->t('Machine name'),
'#default_value' => $registrant_type
->id(),
'#machine_name' => [
'exists' => [
$this,
'exists',
],
],
];
$form['description'] = [
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $registrant_type->description,
];
$form['label_pattern'] = [
'#type' => 'textfield',
'#title' => t('Label Pattern'),
'#default_value' => $registrant_type->label_pattern,
'#description' => t('For anonymous registrants, provide a pattern here to use as its label. Only used if the registrant does not have another identify in the system. Can use tokens - e.g. <b>[registrant:field_first_name] [registrant:field_last_name]</b>'),
];
return $form;
}