You are here

function botcha_point_admin_form in BOTCHA Spam Prevention 7

Same name and namespace in other branches
  1. 6 botcha.pages.inc \botcha_point_admin_form()

Form for adding BOTCHA point.

1 string reference to 'botcha_point_admin_form'
botcha_point_admin in ./botcha.pages.inc
Central handler for BOTCHA point administration (adding, disabling, deleting)

File

./botcha.pages.inc, line 316
Implementation of botcha administration forms.

Code

function botcha_point_admin_form($form, $form_state, $botcha_point_form_id = NULL) {
  $form = array();
  $default_botcha_type = 'default';
  if (isset($botcha_point_form_id)) {

    // use given BOTCHA point form_id
    $form['botcha_point_form_id'] = array(
      '#type' => 'textfield',
      '#title' => t('Form ID'),
      '#description' => t('The Drupal form_id of the form to add the BOTCHA to.'),
      '#value' => check_plain($botcha_point_form_id),
      '#disabled' => TRUE,
    );
    $botcha_point = botcha_get_form_id_setting($botcha_point_form_id);
    if ($botcha_point) {
      $default_botcha_type = $botcha_point->botcha_type;
    }
  }
  else {

    // textfield for BOTCHA point form_id
    $form['botcha_point_form_id'] = array(
      '#type' => 'textfield',
      '#title' => t('Form ID'),
      '#description' => t('The Drupal form_id of the form to add the BOTCHA to.'),
    );
  }

  // select widget for BOTCHA type
  $form['botcha_type'] = array(
    '#type' => 'select',
    '#title' => t('Challenge type'),
    '#description' => t('The BOTCHA type to use for this form'),
    '#default_value' => $default_botcha_type,
    '#options' => _botcha_available_cookbooks(),
  );

  // redirect to general BOTCHA settings page after submission
  $form_state['#redirect'] = 'admin/config/people/botcha';

  // submit button
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}