You are here

function field_hidden_field_widget_form in Field Hidden 7

Defines formatting of a field in a form.

Implements hook_field_widget_form().

Parameters

array $form:

array &$form_state:

array $field:

array $instance:

string $langcode:

array $items:

integer $delta:

array $element:

Return value

array

File

./field_hidden.module, line 835
Drupal Field Hidden module

Code

function field_hidden_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $element['#type'] = 'hidden';
  $value = isset($items[$delta]['value']) ? $items[$delta]['value'] : '';
  switch ($field['type']) {
    case 'field_hidden_integer':
    case 'field_hidden_decimal':
    case 'field_hidden_float':
      if ($field['type'] != 'field_hidden_integer') {
        $value = strtr($value, '.', $field['settings']['decimal_separator']);
      }
      $element['#default_value'] = $value;
      $element['#number_type'] = str_replace('field_hidden_', '', $field['type']);
      break;
    default:
      $element['#default_value'] = $value;
  }
  return array(
    'value' => $element,
  );
}