You are here

function field_hidden_field_instance_settings_form in Field Hidden 7

For editing a particular instance of the field (e.g. 'some_hidden' in current content type).

Implements hook_field_instance_settings_form().

Parameters

array $field:

array $instance:

Return value

array

File

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

Code

function field_hidden_field_instance_settings_form($field, $instance) {
  $fld_set = $field['settings'];
  $form = array();
  switch ($field['type']) {
    case 'field_hidden_integer':
    case 'field_hidden_decimal':
    case 'field_hidden_float':
      $inst_set = $instance['settings'];
      $form['min'] = array(
        '#type' => 'textfield',
        '#title' => t('Minimum'),
        '#default_value' => $inst_set['min'],
        '#description' => t('The minimum value that should be allowed in this field. Leave blank for no minimum.'),
        '#element_validate' => array(
          '_field_hidden_element_validate_number',
        ),
      );
      $form['max'] = array(
        '#type' => 'textfield',
        '#title' => t('Maximum'),
        '#default_value' => $inst_set['max'],
        '#description' => t('The maximum value that should be allowed in this field. Leave blank for no maximum.'),
        '#element_validate' => array(
          '_field_hidden_element_validate_number',
        ),
      );
      $form['display_notice'] = array(
        '#type' => 'markup',
        '#markup' => '<label>' . t('The @prefix and @suffix settings are only relevant if the value of this field should be display in output', array(
          '@prefix' => t('Prefix'),
          '@suffix' => t('Suffix'),
        )) . '</label><div>' . t('See \'@format\' in the \'@manage_display\' section of this content type.', array(
          '@format' => t('Format'),
          '@manage_display' => t('Manage Display'),
        )) . '</div>',
      );
      $form['prefix'] = array(
        '#type' => 'textfield',
        '#title' => t('Prefix'),
        '#default_value' => $inst_set['prefix'],
        '#size' => 60,
        '#description' => t("Define a string that should be prefixed to the value, like '\$ ' or '&euro; '. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
      );
      $form['suffix'] = array(
        '#type' => 'textfield',
        '#title' => t('Suffix'),
        '#default_value' => $inst_set['suffix'],
        '#size' => 60,
        '#description' => t("Define a string that should be suffixed to the value, like ' m', ' kb/s'. Leave blank for none. Separate singular and plural values with a pipe ('pound|pounds')."),
      );
      break;
  }

  //  Turn the default value field into a text field (kind of easier to assess and edit).
  if (!variable_get('field_hidden_instance_settings_hide_defval', FALSE)) {
    $form['display_default_value'] = array(
      '#type' => 'markup',
      '#markup' => '<script type="text/javascript">
(function($) {
  $(document).ready(function() {
    var elm, jq;
    if ((elm = (jq = $("div#edit-' . str_replace('_', '-', $instance['field_name']) . '")).get(0))) {
      jq.removeClass().addClass("form-item form-type-textfield text-full");
      (elm = (jq = $("input", elm)).get(0)).setAttribute("type", "text");
      elm.setAttribute("size", "60");
      jq.addClass("text-full form-text");
    }
  } );
})(jQuery);
</script>',
    );
  }
  return $form;
}