Issue #2349651 by yannisc, larowlan: Fixed Default contact form does not send email as email recipient is not set during the installation.
parent
fa1d2c3c9c
commit
62f8b460fe
|
@ -8,6 +8,7 @@
|
||||||
namespace Drupal\standard\Tests;
|
namespace Drupal\standard\Tests;
|
||||||
|
|
||||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||||
|
use Drupal\contact\Entity\ContactForm;
|
||||||
use Drupal\simpletest\WebTestBase;
|
use Drupal\simpletest\WebTestBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,6 +113,10 @@ class StandardTest extends WebTestBase {
|
||||||
\Drupal::moduleHandler()->uninstall(array('editor', 'ckeditor'));
|
\Drupal::moduleHandler()->uninstall(array('editor', 'ckeditor'));
|
||||||
$this->rebuildContainer();
|
$this->rebuildContainer();
|
||||||
\Drupal::moduleHandler()->install(array('editor'));
|
\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.
|
* Enables modules and site configuration for a standard site installation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Drupal\contact\Entity\ContactForm;
|
||||||
use Drupal\Core\Form\FormStateInterface;
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,4 +15,13 @@ use Drupal\Core\Form\FormStateInterface;
|
||||||
function standard_form_install_configure_form_alter(&$form, FormStateInterface $form_state) {
|
function standard_form_install_configure_form_alter(&$form, FormStateInterface $form_state) {
|
||||||
// Pre-populate the site name with the server name.
|
// Pre-populate the site name with the server name.
|
||||||
$form['site_information']['site_name']['#default_value'] = \Drupal::request()->server->get('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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue