hook_field_settings_form

Versions
7
hook_field_settings_form($field, $instance, $has_data)

Field settings form.

The field type module is responsible for not returning form elements that cannot be changed. It may not always be possible to tell in advance, but modules should attempt to inform the user what is going/likely to work.

@todo: Only the field type module knows which settings will affect the field's schema, but only the field storage module knows what schema changes are permitted once a field already has data. Probably we need an easy way for a field type module to ask whether an update to a new schema will be allowed without having to build up a fake $prior_field structure for hook_field_update_forbid().

Parameters

$field The field structure being configured.

$instance The instance structure being configured.

$has_data Whether the field already has data.

Return value

The form definition for the field settings.

Code

modules/field_ui/field_ui.api.php, line 36

<?php
function hook_field_settings_form($field, $instance, $has_data) {
  $settings = $field['settings'];
  $form['max_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum length'),
    '#default_value' => $settings['max_length'],
    '#required' => FALSE,
    '#element_validate' => array('_element_validate_integer_positive'),
    '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
  );
  return $form;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.