You are here

function geolocation_widget in Geolocation Field 6

Implementation of hook_widget().

Attach a single form element to the form.

CCK core fields only add a stub element and builds the complete item in #process so reusable elements created by hook_elements can be plugged into any module that provides valid $field information.

Custom widgets that don't care about using hook_elements can be built out completely at this time.

If there are multiple values for this field and CCK is handling multiple values, the content module will call this function as many times as needed.

Parameters

$form: the entire form array, $form['#node'] holds node information

$form_state: the form_state, $form_state['values'][$field['field_name']] holds the field's form values.

$field: the field array

$items: array of default values for this field

$delta: the order of this item in the array of subelements (0, 1, 2, etc)

Return value

the form item for a single element for this field

File

./geolocation.module, line 333

Code

function geolocation_widget(&$form, &$form_state, $field, $items, $delta = 0) {
  $lat_value = isset($items[$delta]['lat']) ? $items[$delta]['lat'] : '';
  $lng_value = isset($items[$delta]['lng']) ? $items[$delta]['lng'] : '';
  $element['lat'] = array();
  $element['lng'] = array();
  $element['lat'] += array(
    '#title' => t('Latitude'),
    '#type' => 'textfield',
    '#default_value' => $lat_value,
    '#size' => 30,
    '#maxlength' => 30,
  );
  $element['lng'] += array(
    '#title' => t('Longitude'),
    '#type' => 'textfield',
    '#default_value' => $lng_value,
    '#size' => 30,
    '#maxlength' => 30,
  );
  return $element;
}