You are here

webform_ajax.install in Webform Ajax 7

Same filename and directory in other branches
  1. 7.2 webform_ajax.install

Webform AJAX install file.

Alter Webform table schema to add the AJAX property to a webform.

File

webform_ajax.install
View source
<?php

/**
 * @file
 * Webform AJAX install file.
 *
 * Alter Webform table schema to add the AJAX property to a webform.
 */

/**
 * Implements hook_schema_alter().
 */
function webform_ajax_schema_alter(&$schema) {

  // Define our additional fields.
  if (isset($schema['webform'])) {

    // Declare new column for webform_ajax property.
    $schema['webform']['fields']['webform_ajax'] = array(
      'description' => 'Value of a webform for AJAX with confirm screen (1), no confirm screen (-1) or no AJAX (0).',
      'type' => 'int',
      'size' => 'tiny',
      'not null' => TRUE,
      'default' => 0,
    );
  }
}

/**
 * Implements hook_install().
 */
function webform_ajax_install() {

  // Update schema. Add our additional fields.
  $schema = array(
    'webform' => array(),
  );
  webform_ajax_schema_alter($schema);
  foreach ($schema as $table => $table_def) {
    foreach ($table_def['fields'] as $field => $spec) {
      db_add_field($table, $field, $spec);
    }
  }
}

/**
 * Implements hook_uninstall().
 */
function webform_ajax_uninstall() {

  // Update schema. Drop our additional fields.
  $schema = array(
    'webform' => array(),
  );
  webform_ajax_schema_alter($schema);
  foreach ($schema as $table => $table_def) {
    foreach ($table_def['fields'] as $field => $spec) {
      db_drop_field($table, $field);
    }
  }
}