SharedEmailSettingsForm.php in Shared Email 8.2
File
src/Form/SharedEmailSettingsForm.php
View source
<?php
namespace Drupal\sharedemail\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
class SharedEmailSettingsForm extends ConfigFormBase {
public function getFormId() {
return 'sharedemail_settings_form';
}
protected function getEditableConfigNames() {
return [
'sharedemail.settings',
];
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$config = $this
->config('sharedemail.settings');
$form['sharedemail_msg'] = [
'#type' => 'textarea',
'#title' => $this
->t('Shared E-mail message'),
'#default_value' => $config
->get('sharedemail_msg'),
'#description' => $this
->t('Warning message that is only displayed to users with appropriate permission, when they choose to save an e-mail address already used by another user.'),
];
$form['sharedemail_allowed'] = [
'#type' => 'textfield',
'#title' => $this
->t('Shared E-mail address whitelist'),
'#default_value' => $config
->get('sharedemail_allowed'),
'#description' => $this
->t('Comma separated list of email addresses that may be used to share. Leave blank to allow any.'),
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this
->config('sharedemail.settings')
->set('sharedemail_msg', $form_state
->getValue('sharedemail_msg'))
->set('sharedemail_allowed', $form_state
->getValue('sharedemail_allowed'))
->save();
parent::submitForm($form, $form_state);
}
}