You are here

function field_hidden_field_settings_form in Field Hidden 7

For editing settings that apply to all instances of the field (e.g. 'some_hidden' across all content types).

Implements hook_field_settings_form().

Parameters

array $field:

array $instance:

boolean $has_data:

Return value

array

File

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

Code

function field_hidden_field_settings_form($field, $instance, $has_data) {
  $fld_set = $field['settings'];
  $form = array();
  switch ($field['type']) {
    case 'field_hidden_integer':
    case 'field_hidden_decimal':
    case 'field_hidden_float':
      if ($field['type'] == 'field_hidden_decimal') {
        $form['precision'] = array(
          '#type' => 'select',
          '#title' => t('Numeric precision'),
          '#options' => drupal_map_assoc(range(10, 32)),
          '#default_value' => $fld_set['precision'],
          '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
          '#disabled' => $has_data,
        );
        $form['scale'] = array(
          '#type' => 'select',
          '#title' => t('Numeric scale'),
          '#options' => drupal_map_assoc(range(0, 10)),
          '#default_value' => $fld_set['scale'],
          '#description' => t('The number of digits to the right of the decimal.'),
          '#disabled' => $has_data,
        );
      }
      if ($field['type'] != 'field_hidden_integer') {
        $form['decimal_separator'] = array(
          '#type' => 'select',
          '#title' => t('Decimal marker'),
          '#options' => array(
            '.' => t('Decimal point'),
            ',' => t('Comma'),
          ),
          '#default_value' => $fld_set['decimal_separator'],
          '#description' => t('The character users will input to mark the decimal point in forms.'),
        );
      }
      break;
    default:
      $form['max_length'] = array(
        '#type' => 'textfield',
        '#size' => 5,
        '#title' => t('Maximum length'),
        '#default_value' => $fld_set['max_length'],
        '#required' => TRUE,
        '#description' => t('The maximum length of the field in characters.'),
        '#element_validate' => array(
          '_field_hidden_element_validate_integer_positive',
        ),
        '#disabled' => $has_data,
      );
  }
  return $form;
}