public function NewsletterSettingsForm::buildForm in Simplenews 3.x
Same name and namespace in other branches
- 8.2 src/Form/NewsletterSettingsForm.php \Drupal\simplenews\Form\NewsletterSettingsForm::buildForm()
- 8 src/Form/NewsletterSettingsForm.php \Drupal\simplenews\Form\NewsletterSettingsForm::buildForm()
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides ConfigFormBase::buildForm
File
- src/
Form/ NewsletterSettingsForm.php, line 30
Class
- NewsletterSettingsForm
- Configure simplenews newsletter settings.
Namespace
Drupal\simplenews\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this
->config('simplenews.settings');
$form['simplenews_default_options'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Default newsletter options'),
'#collapsible' => FALSE,
'#description' => $this
->t('These options will be the defaults for new newsletters, but can be overridden in the newsletter editing form.'),
];
$links = [
':swiftmailer_url' => 'http://drupal.org/project/swiftmailer',
];
$description = $this
->t('Default newsletter format. Install <a href=":swiftmailer_url">Swift Mailer</a> module to send newsletters in HTML format.', $links);
$form['simplenews_default_options']['simplenews_format'] = [
'#type' => 'select',
'#title' => $this
->t('Format'),
'#options' => simplenews_format_options(),
'#description' => $description,
'#default_value' => $config
->get('newsletter.format'),
];
// @todo Do we need these master defaults for 'priority' and 'receipt'?
$form['simplenews_default_options']['simplenews_priority'] = [
'#type' => 'select',
'#title' => $this
->t('Priority'),
'#options' => simplenews_get_priority(),
'#description' => $this
->t('Note that email priority is ignored by a lot of email programs.'),
'#default_value' => $config
->get('newsletter.priority'),
];
$form['simplenews_default_options']['simplenews_receipt'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Request receipt'),
'#default_value' => $config
->get('newsletter.receipt'),
'#description' => $this
->t('Request a Read Receipt from your newsletters. A lot of email programs ignore these so it is not a definitive indication of how many people have read your newsletter.'),
];
$form['simplenews_sender_info'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Sender information'),
'#collapsible' => FALSE,
'#description' => $this
->t("Default sender address that will only be used for confirmation emails. You can specify sender information for each newsletter separately on the newsletter's settings page."),
];
$form['simplenews_sender_info']['simplenews_from_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('From name'),
'#size' => 60,
'#maxlength' => 128,
'#default_value' => $config
->get('newsletter.from_name'),
];
$form['simplenews_sender_info']['simplenews_from_address'] = [
'#type' => 'email',
'#title' => $this
->t('From email address'),
'#size' => 60,
'#maxlength' => 128,
'#required' => TRUE,
'#default_value' => $config
->get('newsletter.from_address'),
];
return parent::buildForm($form, $form_state);
}