You are here

function resource_conflict_form_alter in Resource Conflict 5

Same name and namespace in other branches
  1. 5.2 resource_conflict.module \resource_conflict_form_alter()
  2. 6.2 resource_conflict.module \resource_conflict_form_alter()
  3. 7.3 resource_conflict.module \resource_conflict_form_alter()
  4. 7.2 resource_conflict.module \resource_conflict_form_alter()

Implementation of hook_form_alter

File

./resource_conflict.module, line 57

Code

function resource_conflict_form_alter($form_id, &$form) {
  if ($form_id == 'node_type_form') {
    $type = isset($form['old_type']) && isset($form['old_type']['#value']) ? $form['old_type']['#value'] : NULL;
    $form['resource_conflict_set'] = array(
      '#type' => 'fieldset',
      '#title' => t('Resource Conflict'),
      '#collapsible' => TRUE,
    );
    $form['resource_conflict_set']['resource_conflict'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable resource conflict checking for this content type.'),
      '#default_value' => variable_get('resource_conflict_' . $type, 0),
      '#description' => t('If this is enabled, this content type must also be event enabled.'),
    );
    if ($type != NULL) {
      $fields = content_fields();
      foreach ($fields as $field) {
        if ($field['type'] == 'nodereference') {
          $nodereference_fields[$field['field_name']] = $field['widget']['label'];
        }
      }
    }
    if (empty($nodereference_fields)) {
      $form['resource_conflict_set']['no_nodreference_fields'] = array(
        '#value' => t('Please create some nodereference fields for this content type.'),
      );
    }
    else {
      $form['resource_conflict_set']['resource_conflict_fields'] = array(
        '#type' => 'select',
        '#title' => t('Fields to check for conflicts'),
        '#options' => $nodereference_fields,
        '#multiple' => TRUE,
        '#default_value' => variable_get('resource_conflict_fields_' . $type, FALSE),
        '#description' => t("Select the node reference resources which can't be booked at the same time."),
      );
    }
  }
}