Commit 62f8b460 authored by alexpott's avatar alexpott

Issue #2349651 by yannisc, larowlan: Fixed Default contact form does not send...

Issue #2349651 by yannisc, larowlan: Fixed Default contact form does not send email as email recipient is not set during the installation.
parent fa1d2c3c
......@@ -8,6 +8,7 @@
namespace Drupal\standard\Tests;
use Drupal\config\Tests\SchemaCheckTestTrait;
use Drupal\contact\Entity\ContactForm;
use Drupal\simpletest\WebTestBase;
/**
......@@ -112,6 +113,10 @@ function testStandard() {
\Drupal::moduleHandler()->uninstall(array('editor', 'ckeditor'));
$this->rebuildContainer();
\Drupal::moduleHandler()->install(array('editor'));
/** @var \Drupal\contact\ContactFormInterface $contact_form */
$contact_form = ContactForm::load('feedback');
$recipients = $contact_form->getRecipients();
$this->assertEqual(['simpletest@example.com'], $recipients);
}
}
......@@ -4,6 +4,7 @@
* Enables modules and site configuration for a standard site installation.
*/
use Drupal\contact\Entity\ContactForm;
use Drupal\Core\Form\FormStateInterface;
/**
......@@ -14,4 +15,13 @@
function standard_form_install_configure_form_alter(&$form, FormStateInterface $form_state) {
// Pre-populate the site name with the server name.
$form['site_information']['site_name']['#default_value'] = \Drupal::request()->server->get('SERVER_NAME');
$form['#submit'][] = 'standard_form_install_configure_submit';
}
/**
* Submission handler to sync the contact.form.feedback recipient.
*/
function standard_form_install_configure_submit($form, FormStateInterface $form_state) {
$site_mail = $form_state->getValue('site_mail');
ContactForm::load('feedback')->setRecipients([$site_mail])->save();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment