function simplenews_form_node_form_alter in Simplenews 8
Same name and namespace in other branches
- 8.2 simplenews.module \simplenews_form_node_form_alter()
- 3.x simplenews.module \simplenews_form_node_form_alter()
Implements hook_form_alter().
File
- ./
simplenews.module, line 277 - Simplenews node handling, sent email, newsletter block and general hooks
Code
function simplenews_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Add Simplenews settings to simplenews newsletter node form.
$node = $form_state
->getFormObject()
->getEntity();
if (in_array($node
->getType(), simplenews_get_content_types())) {
// Display warning if the node is currently being sent.
if (!$node
->isNew()) {
if ($node->simplenews_issue->status == SIMPLENEWS_STATUS_SEND_PENDING) {
\Drupal::messenger()
->addWarning(t('This newsletter issue is currently being sent. Any changes will be reflected in the e-mails which have not been sent yet.'));
}
}
if (\Drupal::moduleHandler()
->moduleExists('token')) {
$form['simplenews_token_help'] = array(
'#title' => t('Replacement patterns'),
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('These tokens can be used in all text fields except subject and will be replaced on-screen and in the email.'),
);
$form['simplenews_token_help']['browser'] = array(
'#theme' => 'token_tree_link',
'#token_types' => array(
'simplenews-newsletter',
'simplenews-subscriber',
'node',
),
);
}
}
}