list_field_settings_form($field, $instance, $has_data)Implements hook_field_settings_form().
@todo: If $has_data, add a form validate function to verify that the new allowed values do not exclude any keys for which data already exists in the databae (use field_attach_query()) to find out. Implement the validate function via hook_field_update_forbid() so list.module does not depend on form submission.
modules/field/modules/list/list.module, line 107
<?php
function list_field_settings_form($field, $instance, $has_data) {
$settings = $field['settings'];
$form['allowed_values'] = array(
'#type' => 'textarea',
'#title' => t('Allowed values list'),
'#default_value' => $settings['allowed_values'],
'#required' => FALSE,
'#rows' => 10,
'#description' => '<p>' . t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and must be a %type value. The label is optional, and the key will be used as the label if no label is specified.', array('%type' => $field['type'] == 'list_text' ? t('text') : t('numeric'))) . '</p>',
'#element_validate' => array('list_allowed_values_setting_validate'),
'#list_field_type' => $field['type'],
'#access' => empty($settings['allowed_values_function']),
);
// Alter the description for allowed values depending on the widget type.
if ($instance['widget']['type'] == 'options_onoff') {
$form['allowed_values']['#description'] .= '<p>' . t("For a 'single on/off checkbox' widget, define the 'off' value first, then the 'on' value in the <strong>Allowed values</strong> section. Note that the checkbox will be labeled with the label of the 'on' value.") . '</p>';
}
elseif ($instance['widget']['type'] == 'options_buttons') {
$form['allowed_values']['#description'] .= '<p>' . t("The 'checkboxes/radio buttons' widget will display checkboxes if the <em>Number of values</em> option is greater than 1 for this field, otherwise radios will be displayed.") . '</p>';
}
$form['allowed_values']['#description'] .= t('Allowed HTML tags in labels: @tags', array('@tags' => _field_filter_xss_display_allowed_tags()));
$form['allowed_values_function'] = array(
'#type' => 'value',
'#value' => $settings['allowed_values_function'],
);
$form['allowed_values_function_display'] = array(
'#type' => 'item',
'#title' => t('Allowed values list'),
'#markup' => t('The value of this field is being determined by the %function function and may not be changed.', array('%function' => $settings['allowed_values_function'])),
'#access' => !empty($settings['allowed_values_function']),
);
return $form;
}
?>