public function ContactEmailForm::submitForm in Contact Emails 8
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
Overrides ContentEntityForm::submitForm
File
- src/
Form/ ContactEmailForm.php, line 367
Class
- ContactEmailForm
- Defines the tax service add/edit form.
Namespace
Drupal\contact_emails\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
/** @var \Drupal\contact_emails\ContactEmailStorageInterface $storage */
$storage = \Drupal::entityTypeManager()
->getStorage('contact_email');
// Warn the user if they are disabling the core contact emails for the
// first time.
$has_emails = $storage
->hasContactEmails($values['contact_form'][0]['target_id'], TRUE);
if (!$has_emails && $this->entity
->isNew()) {
$this
->messenger()
->addWarning($this
->t('The default contact email from the form settings has been disabled and your new email has replaced it.'));
}
// Save the contact email and rebuild the cache.
parent::submitForm($form, $form_state);
$this->contactEmails
->rebuildCache();
}