function _autocomplete_widgets_content_field_edit_form_alter in Autocomplete Widgets for Text and Number Fields 6
Alter the CCK widget settings form.
1 call to _autocomplete_widgets_content_field_edit_form_alter()
- autocomplete_widgets_form_alter in ./
autocomplete_widgets.module - Implementation of hook_form_alter().
File
- ./
autocomplete_widgets.admin.inc, line 11 - Administration related code for Autocomplete Widgets module.
Code
function _autocomplete_widgets_content_field_edit_form_alter(&$form, $form_state) {
$widget_type = $form['#field']['widget']['type'];
if (in_array($widget_type, array(
'autocomplete_widgets_allowvals',
'autocomplete_widgets_flddata',
))) {
// Implementation of allowed values list.
if ($widget_type == 'autocomplete_widgets_allowvals') {
$form['field']['allowed_values_fieldset']['#collapsed'] = FALSE;
$form['field']['allowed_values_fieldset']['#description'] = '<p>' . t('Create a list of options as a list in <strong>Allowed values list</strong> or as an array in PHP code. These values will be the same for %field in all content types.', array(
'%field' => $form['#field']['widget']['label'],
)) . '</p>';
// If no 'allowed values' were set yet, add a remainder in the messages area.
if (empty($form_state['post']) && empty($form['field']['allowed_values_fieldset']['allowed_values']['#default_value']) && empty($form['field']['allowed_values_fieldset']['advanced_options']['allowed_values_php']['#default_value'])) {
drupal_set_message(t("You need to specify the 'allowed values' for this field."), 'warning');
}
}
else {
// For the autocomplete 'field data' widget we do not use the 'Allowed values' list.
unset($form['field']['allowed_values_fieldset']);
}
// Disable the text processing option of text fields. These widgets can
// only use plain text fields.
if (isset($form['field']['text_processing'])) {
$form['field']['text_processing']['#type'] = 'value';
$form['field']['text_processing']['#value'] = 0;
}
}
}