You are here

function context_form_alter in Context 6.2

Same name and namespace in other branches
  1. 8.4 context.module \context_form_alter()
  2. 6.3 context.core.inc \context_form_alter()
  3. 6 context.core.inc \context_form_alter()
  4. 7.3 context.core.inc \context_form_alter()

Implementation of hook_form_alter().

File

./context.core.inc, line 363

Code

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

  // Prevent this from firing on admin pages... damn form driven apis...
  if ($form['#id'] === 'node-form' && arg(0) != 'admin') {
    context_node_condition($form['#node'], 'form');
    $form['#validate'][] = 'context_form_alter_node_validate';
  }
  if ($form_id == 'system_modules') {
    context_invalidate_cache();
  }
  if ($form_id == 'taxonomy_form_vocabulary') {

    // Add the option to include this vocabulary in context conditions:
    $vid = isset($form['vid']['#value']) ? $form['vid']['#value'] : 0;
    $form['settings']['context'] = array(
      '#type' => 'checkbox',
      '#title' => t('Include as context condition'),
      '#description' => t('Select to make this vocabulary available for use as a context condition.'),
      '#default_value' => in_array($vid, variable_get('context_taxonomy_vocabularies', array())),
    );

    // Add our submit handler:
    $form['#submit'][] = 'content_taxonomy_form_vocabulary_submit';
  }
}