public function RegistrationTypeDeleteForm::buildForm in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Form/RegistrationTypeDeleteForm.php \Drupal\rng\Form\RegistrationTypeDeleteForm::buildForm()
- 3.x src/Form/RegistrationTypeDeleteForm.php \Drupal\rng\Form\RegistrationTypeDeleteForm::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 EntityConfirmFormBase::buildForm
File
- src/
Form/ RegistrationTypeDeleteForm.php, line 39
Class
- RegistrationTypeDeleteForm
- Form controller for registration types.
Namespace
Drupal\rng\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$count = $this->entityManager
->getStorage('registration')
->getQuery()
->condition('type', $this->entity
->id())
->count()
->execute();
if ($count == 0) {
return parent::buildForm($form, $form_state);
}
drupal_set_message($this
->t('Cannot delete registration type.'), 'warning');
$form['#title'] = $this
->getQuestion();
$form['description'] = array(
'#markup' => $this
->formatPlural($count, 'Unable to delete registration type. It is used by @count registration.', 'Unable to delete registration type. It is used by @count registrations.'),
);
return $form;
}