You are here

function timefield_field_formatter_settings_form in Timefield 7

Implements hook_field_formatter_settings_form().

File

./timefield.module, line 370
Defines a Field API field for time

Code

function timefield_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $instance_settings = $instance['settings'];
  $element = array();
  $instance_class = str_replace('_', '-', $instance['field_name']);
  if ($display['type'] == 'timefield_duration') {
    $element['duration_format'] = array(
      '#title' => t('Time Duration Format'),
      '#type' => 'select',
      '#options' => _timefield_duration_options(),
      '#default_value' => $settings['duration_format'],
      '#required' => TRUE,
    );
    $element += _timefield_display_format_form('display_format', "Time Input Settings", $settings);
  }
  if ($display['type'] == 'timefield_default') {
  }
  if ($display['type'] == 'timefield_weekly_summary_minical') {
    $js_settings = _timefield_js_settings($instance_class, $instance_settings['input_format']);
    $element['#attached'] = array(
      'library' => array(
        array(
          'timefield',
          'timepicker',
        ),
      ),
      'js' => array(
        drupal_get_path('module', 'timefield') . '/js/timefield.js',
        array(
          'data' => array(
            'timefield' => $js_settings,
          ),
          'type' => 'setting',
        ),
      ),
    );
    $element += _timefield_display_format_form('column_format', "Column Time Settings", $settings);
    $element['first_day'] = array(
      '#title' => t('First Day of the Week'),
      '#type' => 'select',
      '#options' => _timefield_weekly_summary_days(),
      '#default_value' => $settings['first_day'],
      '#required' => TRUE,
    );
    $element['absolute_start'] = array(
      '#title' => t('Mini Cal Start Time'),
      '#description' => t('The Start Time of the Calendar'),
      '#type' => 'textfield',
      '#default_value' => $settings['absolute_start'],
      '#size' => 15,
      '#maxlength' => 15,
      '#attributes' => array(
        'class' => array(
          'edit-timefield-timepicker',
          $instance_class,
        ),
      ),
    );
    $element['absolute_end'] = array(
      '#title' => t('Mini Cal End Time'),
      '#description' => t('The End Time of the Calendar'),
      '#type' => 'textfield',
      '#default_value' => $settings['absolute_end'],
      '#size' => 15,
      '#maxlength' => 15,
      '#attributes' => array(
        'class' => array(
          'edit-timefield-timepicker',
          $instance_class,
        ),
      ),
    );
    $element['range'] = array(
      '#type' => 'select',
      '#title' => t('Select the time duration of each block of time'),
      '#options' => array(
        30 => '30 Minutes',
        60 => '1 Hour',
        90 => '90 minutes',
        120 => '2 Hours',
        180 => '3 Hours',
        240 => '4 Hours',
      ),
      '#default_value' => $settings['range'],
    );
    $element['adjust_range'] = array(
      '#type' => 'checkbox',
      '#title' => t('Adjust Range to fit Items'),
      '#default_value' => $settings['adjust_time'],
    );
  }
  if ($display['type'] == 'timefield_weekly_summary_minical' || $display['type'] == 'timefield_default') {
    $element += _timefield_display_format_form('display_format', "Individual Time Display Settings", $settings);
  }
  return $element;
}