You are here

function text_field_settings_form in Drupal 7

Implements hook_field_settings_form().

File

modules/field/modules/text/text.module, line 62
Defines simple text field types.

Code

function text_field_settings_form($field, $instance, $has_data) {
  $settings = $field['settings'];
  $form = array();
  if ($field['type'] == 'text') {
    $form['max_length'] = array(
      '#type' => 'textfield',
      '#title' => t('Maximum length'),
      '#default_value' => $settings['max_length'],
      '#required' => TRUE,
      '#description' => t('The maximum length of the field in characters.'),
      '#element_validate' => array(
        'element_validate_integer_positive',
      ),
      // @todo: If $has_data, add a validate handler that only allows
      // max_length to increase.
      '#disabled' => $has_data,
    );
  }
  return $form;
}