You are here

function farm_quick_configure_form in farmOS 7

Form for configuring quick forms.

1 string reference to 'farm_quick_configure_form'
farm_quick_menu in modules/farm/farm_quick/farm_quick.module
Implements hook_menu().

File

modules/farm/farm_quick/farm_quick.module, line 191
Code for the Farm Quick module.

Code

function farm_quick_configure_form($form, &$form_state) {

  // Load the list of quick forms.
  $quick_forms = farm_quick_forms();

  // If there are no forms, bail.
  if (empty($quick_forms)) {
    $form['empty'] = array(
      '#type' => 'markup',
      '#markup' => 'There are no quick forms available.',
    );
    return $form;
  }

  // Create a set of checkbox options for the forms.
  $options = array();
  foreach ($quick_forms as $name => $info) {
    if (!empty($info['label'])) {
      $options[$name] = $info['label'];
    }
  }

  // Load the list of enabled quick forms from a variable.
  $enabled_quick_forms = variable_get('farm_quick_forms_enabled', array());

  // Display as a list of checkboxes.
  $form['farm_quick_forms_enabled'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Enable or disable quick forms'),
    '#options' => $options,
    '#default_value' => $enabled_quick_forms,
  );

  // Wrap it in a system settings form.
  $form = system_settings_form($form);

  // Add a submit function that will rebuild the menu tabs (to run after the
  // system_settings_form() submit function.
  $form['#submit'][] = 'farm_quick_configure_form_submit';

  // Return the form.
  return $form;
}