/** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $pid = $form_state->getValue('pid'); $persons = EAPeopleStorage::load(array('pid' => $pid)); if (!empty($persons)) { $person = $persons[0]; // Delete the person. EAPeopleStorage::delete(array('pid' => $pid)); drupal_set_message(t('Deleted @nickname @firstname @lastnames', array('@nickname' => $person->nickname, '@firstname' => $person->firstname, '@lastnames' => $person->lastnames))); } else { drupal_set_message(t('Person not found')); } // Redirect the user to the list controller when complete. $form_state->setRedirectUrl($this->getCancelUrl()); }