You are here

function office_hours_form_alter in Office Hours 6

Same name and namespace in other branches
  1. 6.2 office_hours.module \office_hours_form_alter()

Implementation of hook_form_alter().

File

./office_hours.module, line 43
Creates a field and widget for inserting working or office hours per day

Code

function office_hours_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'content_field_edit_form') {
    if ($form['#field']['type'] == 'office_hours') {
      $description = t('14 hours blocks is the current default. See below for limiting it');
      $description .= '<br/><strong>' . t('Warning! Changing this setting after data has been created could result in the loss of data!') . '</strong>';
      $form['field']['multiple'] = array(
        '#type' => 'select',
        '#title' => t('Number of values'),
        '#options' => drupal_map_assoc(array(
          14,
        )),
        '#default_value' => 14,
        '#description' => $description,
      );
    }
  }
  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] . '_node_form' == $form_id) {
    $type = content_types($form['#node']->type);
    foreach ($type['fields'] as $field) {
      if ($field['type'] == 'office_hours') {
        $form[$field['field_name']]['#theme'] = 'office_hours_multiple_values';
      }
    }
  }
}