You are here

function nat_settings_form in Node Auto Term [NAT] 7

Same name and namespace in other branches
  1. 5 nat.module \nat_settings_form()
  2. 6.2 nat.admin.inc \nat_settings_form()
  3. 6 nat.admin.inc \nat_settings_form()
  4. 7.2 nat.admin.inc \nat_settings_form()

Menu callback: NAT module settings form.

1 string reference to 'nat_settings_form'
nat_menu in ./nat.module
Implements hook_menu().

File

./nat.admin.inc, line 11
NAT module administrative forms.

Code

function nat_settings_form() {
  $types = node_type_get_types();
  $vocabularies = _nat_get_vocabularies();
  if (empty($vocabularies)) {
    drupal_set_message(t('The NAT module requires at least one vocabulary to be defined.'), 'error');
    drupal_goto('admin/content/taxonomy');
  }
  $nat_config = _nat_variable_get();
  $form['nat_node_config'] = array(
    '#type' => 'vertical_tabs',
  );
  foreach ($types as $type => $type_object) {
    $collapsed = !isset($nat_config['types'][$type]) || empty($nat_config['types'][$type]);
    $form['nat_' . $type] = array(
      '#type' => 'fieldset',
      '#title' => check_plain($type_object->name),
      '#group' => 'nat_node_config',
      '#collapsible' => TRUE,
      '#collapsed' => $collapsed,
    );
    $form['nat_' . $type][$type] = array(
      '#type' => 'select',
      '#title' => t('Vocabularies'),
      '#options' => $vocabularies,
      '#default_value' => isset($nat_config['types'][$type]) ? $nat_config['types'][$type] : array(),
      '#multiple' => TRUE,
      '#description' => t('Creating a node of type %type will automatically create a term in any selected vocabularies.', array(
        '%type' => $type,
      )),
      '#parents' => array(
        'types',
        $type,
      ),
    );
    $form['nat_' . $type]['delete_' . $type] = array(
      '#type' => 'checkbox',
      '#title' => t('Delete associated term if a node is deleted.'),
      '#default_value' => isset($nat_config['delete'][$type]) ? $nat_config['delete'][$type] : 0,
      '#parents' => array(
        'delete',
        $type,
      ),
    );
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save configuration'),
  );
  return $form;
}