You are here

function nodeformsettings_form_alter in Node and Comments Form Settings 7.3

Same name and namespace in other branches
  1. 6.3 nodeformsettings.module \nodeformsettings_form_alter()
  2. 6 nodeformsettings.module \nodeformsettings_form_alter()
  3. 6.2 nodeformsettings.module \nodeformsettings_form_alter()
  4. 7.2 nodeformsettings.module \nodeformsettings_form_alter()

Implements hook_form_alter().

File

./nodeformsettings.module, line 79

Code

function nodeformsettings_form_alter(&$form, $form_state, $form_id) {

  // When configuring the content type settings.
  if ($form_id == 'node_type_form') {

    // Get the path to the includes dir.
    $path = drupal_get_path("module", "nodeformsettings") . '/includes/';

    // Save the name of the variable for use in the submit callback.
    $form['var'] = array(
      '#type' => 'hidden',
      '#value' => $form['#node_type']->type,
    );

    // Get the default settings using variable_get and the current content type.
    $settings = nodeformsettings_get_settings($form['#node_type']->type);
    if (isset($settings)) {

      // Load the settings.
      include_once DRUPAL_ROOT . '/' . $path . 'settings_node.inc';

      // Get the form with the settings.
      _nodeformsettings_settings_form($form, $settings);
    }

    // To save the values in an keyed array we need to define a custom submit callback.
    $form['#submit'][] = 'nodeformsettings_settings_submit';
  }
}