public function RegistrantTypeDeleteForm::buildForm in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/Form/Entity/RegistrantTypeDeleteForm.php \Drupal\rng\Form\Entity\RegistrantTypeDeleteForm::buildForm()
- 8 src/Form/Entity/RegistrantTypeDeleteForm.php \Drupal\rng\Form\Entity\RegistrantTypeDeleteForm::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 EntityDeleteForm::buildForm
File
- src/
Form/ Entity/ RegistrantTypeDeleteForm.php, line 47
Class
- RegistrantTypeDeleteForm
- Form controller to delete a registrant type.
Namespace
Drupal\rng\Form\EntityCode
public function buildForm(array $form, FormStateInterface $form_state) {
/** @var \Drupal\rng\Entity\RegistrantTypeInterface $registrant_type */
$registrant_type =& $this->entity;
$count = $this->entityTypeManager
->getStorage('registrant')
->getQuery()
->condition('type', $registrant_type
->id())
->count()
->execute();
if ($count > 0) {
$this
->messenger()
->addMessage($this
->t('Cannot delete registrant type.'), 'warning');
$form['#title'] = $this
->getQuestion();
$form['description'] = [
'#markup' => $this
->formatPlural($count, 'Unable to delete registrant type. It is used by @count registration.', 'Unable to delete registrant type. It is used by @count registrations.'),
];
}
else {
$form = parent::buildForm($form, $form_state);
}
return $form;
}