You are here

function tzfield_geofield_field_widget_settings_form in Time Zone Field 7

Implements hook_field_widget_settings_form().

File

tzfield_geofield/tzfield_geofield.module, line 27
Populate a time zone field from Geofield.

Code

function tzfield_geofield_field_widget_settings_form($field, $instance) {
  $widget_settings = $instance['widget']['settings'];
  $options = array();
  foreach (field_info_instances($instance['entity_type'], $instance['bundle']) as $field_name => $field_instance) {
    $field = field_info_field($field_name);
    if ($field['type'] == 'geofield') {
      $options[$field['field_name']] = $field['field_name'];
    }
  }
  $form['geofield'] = array(
    '#type' => 'select',
    '#title' => 'Geofield',
    '#options' => $options,
    '#default_value' => isset($widget_settings['geofield']) ? $widget_settings['geofield'] : '',
    '#required' => TRUE,
  );
  return $form;
}