You are here

function forward_form_alter in Forward 8

Same name and namespace in other branches
  1. 8.3 forward.module \forward_form_alter()
  2. 8.2 forward.module \forward_form_alter()
  3. 5 forward.module \forward_form_alter()
  4. 6 forward.module \forward_form_alter()
  5. 7.3 forward.module \forward_form_alter()
  6. 7 forward.module \forward_form_alter()
  7. 7.2 forward.module \forward_form_alter()

Implements hook_form_alter().

File

./forward.module, line 183
Allows forwarding of entities by email.

Code

function forward_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Add the node-type settings option to activate the email this page link
  if ($form_id == 'node_type_edit_form') {
    $settings = \Drupal::config('forward.settings')
      ->get();
    $url = Url::fromUri('internal:/admin/config/user-interface/forward');
    $node_type = \Drupal::routeMatch()
      ->getParameters()
      ->get('node_type')
      ->id();
    $form['#node_type'] = $node_type;
    $form['workflow']['forward_node'] = array(
      '#type' => 'checkbox',
      '#title' => t('Show forwarding link/form'),
      '#return_value' => 1,
      '#default_value' => $settings['forward_node_' . $node_type],
      '#description' => t('Further configuration is available on the <a href="@settings-url">Forward settings page</a>.', array(
        '@settings-url' => $url
          ->toString(),
      )),
    );
    $form['actions']['submit']['#submit'][] = 'forward_node_type_edit_form_submit';
  }
}