You are here

function computed_field_field_widget_form in Computed Field 7

Implements hook_field_widget_form().

File

./computed_field.module, line 347
Functionality for the computed field.

Code

function computed_field_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  // If there are no items yet, add a null item value to avoid
  // preview errors when selecting a different language.
  if (empty($items)) {
    $items[0]['value'] = NULL;
  }
  foreach ($items as $item_delta => $item) {
    $element[$item_delta]['value'] = array(
      '#type' => 'value',
      '#tree' => TRUE,
      '#default_value' => isset($item['value']) ? $item['value'] : NULL,
    );
  }
  return $element;
}