diff --git a/includes/form.inc b/includes/form.inc index c3e5954..63c322a 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -3395,9 +3395,6 @@ function form_process_tableselect($element) { * different character, 'replace_pattern' needs to be set accordingly. * - error: (optional) A custom form error message string to show, if the * machine name contains disallowed characters. - * - standalone: (optional) Whether the live preview should stay in its own - * form element rather than in the suffix of the source element. Defaults - * to FALSE. * - #maxlength: (optional) Should be set to the maximum allowed length of the * machine name. Defaults to 64. * - #disabled: (optional) Should be set to TRUE in case an existing machine @@ -3409,9 +3406,6 @@ function form_process_machine_name($element, &$form_state) { '#title' => t('Machine-readable name'), '#description' => t('A unique machine-readable name. Can only contain lowercase letters, numbers, and underscores.'), '#machine_name' => array(), - '#field_prefix' => '', - '#field_suffix' => '', - '#suffix' => '', ); // A form element that only wants to set one #machine_name property (usually // 'source' only) would leave all other properties undefined, if the defaults @@ -3422,9 +3416,6 @@ function form_process_machine_name($element, &$form_state) { 'label' => t('Machine name'), 'replace_pattern' => '[^a-z0-9_]+', 'replace' => '_', - 'standalone' => FALSE, - 'field_prefix' => $element['#field_prefix'], - 'field_suffix' => $element['#field_suffix'], ); // By default, machine names are restricted to Latin alphanumeric characters. @@ -3440,7 +3431,7 @@ function form_process_machine_name($element, &$form_state) { } // Retrieve the form element containing the human-readable name from the - // complete form in $form_state. By reference, because we may need to append + // complete form in $form_state. By reference, because we need to append // a #field_suffix that will hold the live preview. $key_exists = NULL; $source = drupal_array_get_nested_value($form_state['complete form'], $element['#machine_name']['source'], $key_exists); @@ -3448,21 +3439,16 @@ function form_process_machine_name($element, &$form_state) { return $element; } + // Append a field suffix to the source form element, which will contain + // the live preview of the machine name. $suffix_id = $source['#id'] . '-machine-name-suffix'; - $element['#machine_name']['suffix'] = '#' . $suffix_id; + $source += array('#field_suffix' => ''); + $source['#field_suffix'] .= ' '; - if ($element['#machine_name']['standalone']) { - $element['#suffix'] .= ' '; - } - else { - // Append a field suffix to the source form element, which will contain - // the live preview of the machine name. - $source += array('#field_suffix' => ''); - $source['#field_suffix'] .= ' '; + $parents = array_merge($element['#machine_name']['source'], array('#field_suffix')); + drupal_array_set_nested_value($form_state['complete form'], $parents, $source['#field_suffix']); - $parents = array_merge($element['#machine_name']['source'], array('#field_suffix')); - drupal_array_set_nested_value($form_state['complete form'], $parents, $source['#field_suffix']); - } + $element['#machine_name']['suffix'] = '#' . $suffix_id; $js_settings = array( 'type' => 'setting', diff --git a/misc/machine-name.js b/misc/machine-name.js index 66eb9d4..3f8e788 100644 --- a/misc/machine-name.js +++ b/misc/machine-name.js @@ -19,10 +19,6 @@ Drupal.behaviors.machineName = { * disallowed characters in the machine name; e.g., '[^a-z0-9]+'. * - replace: A character to replace disallowed characters with; e.g., '_' * or '-'. - * - standalone: Whether the preview should stay in its own element rather - * than the suffix of the source element. - * - field_prefix: The #field_prefix of the form element. - * - field_suffix: The #field_suffix of the form element. */ attach: function (context, settings) { var self = this; @@ -53,12 +49,10 @@ Drupal.behaviors.machineName = { var machine = self.transliterate($source.val(), options); } // Append the machine name preview to the source field. - var $preview = $('' + options.field_prefix + Drupal.checkPlain(machine) + options.field_suffix + ''); - $suffix.empty(); - if (options.label) { - $suffix.append(' ').append('' + options.label + ':'); - } - $suffix.append(' ').append($preview); + var $preview = $('' + machine + ''); + $suffix.empty() + .append(' ').append('' + options.label + ':') + .append(' ').append($preview); // If the machine name cannot be edited, stop further processing. if ($target.is(':disabled')) { @@ -86,7 +80,7 @@ Drupal.behaviors.machineName = { if (machine != '') { if (machine != options.replace) { $target.val(machine); - $preview.html(options.field_prefix + Drupal.checkPlain(machine) + options.field_suffix); + $preview.text(machine); } $suffix.show(); } diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index 33ce2f0..f19429d 100644 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -316,7 +316,7 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle t('Label'), t('Weight'), t('Parent'), - t('Machine name'), + t('Name'), t('Field'), t('Widget'), array('data' => t('Operations'), 'colspan' => 2), @@ -498,24 +498,16 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle ), ), 'field_name' => array( - '#type' => 'machine_name', + '#type' => 'textfield', '#title' => t('New field name'), '#title_display' => 'invisible', // This field should stay LTR even for RTL languages. '#field_prefix' => 'field_', '#field_suffix' => '', - '#size' => 15, - '#description' => t('A unique machine-readable name containing letters, numbers, and underscores.'), - // 32 characters minus the 'field_' prefix. - '#maxlength' => 26, + '#attributes' => array('dir'=>'ltr'), + '#size' => 10, + '#description' => t('Field name (a-z, 0-9, _)'), '#prefix' => '