diff --git a/core/includes/form.inc b/core/includes/form.inc index 8546835..b91a882 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -3335,7 +3335,7 @@ function form_process_tableselect($element) { * - 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 it's own - * form element rather than in the prefix of the source element. Defaults + * 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. @@ -3350,7 +3350,7 @@ function form_process_machine_name($element, &$form_state) { '#machine_name' => array(), '#field_prefix' => '', '#field_suffix' => '', - '#prefix' => '', + '#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 @@ -3379,7 +3379,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 need to append + // complete form in $form_state. By reference, because we may 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); @@ -3390,7 +3390,10 @@ function form_process_machine_name($element, &$form_state) { $suffix_id = $source['#id'] . '-machine-name-suffix'; $element['#machine_name']['suffix'] = '#' . $suffix_id; - if (!$element['#machine_name']['standalone']) { + 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' => ''); @@ -3399,9 +3402,6 @@ function form_process_machine_name($element, &$form_state) { $parents = array_merge($element['#machine_name']['source'], array('#field_suffix')); drupal_array_set_nested_value($form_state['complete_form'], $parents, $source['#field_suffix']); } - else { - $element['#prefix'] .= ' '; - } $js_settings = array( 'type' => 'setting', diff --git a/core/misc/machine-name.js b/core/misc/machine-name.js index 59db638..ddd32f7 100644 --- a/core/misc/machine-name.js +++ b/core/misc/machine-name.js @@ -20,7 +20,7 @@ Drupal.behaviors.machineName = { * - replace: A character to replace disallowed characters with; e.g., '_' * or '-'. * - standalone: Whether the preview should stay in it's own element rather - * than the prefix of the source element. + * 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. */ @@ -37,17 +37,12 @@ Drupal.behaviors.machineName = { } // Skip processing upon a form validation error on the machine name. if ($target.hasClass('error')) { - $suffix.hide(); return; } // Figure out the maximum length for the machine name. options.maxlength = $target.attr('maxlength'); - // Hide the form item of the machine name form element. - $wrapper.children().hide(); - if (options.standalone) { - $wrapper.find('.description').show(); - } - + // Hide the form item container of the machine name form element. + $wrapper.hide(); // Determine the initial machine name value. Unless the machine name form // element is disabled or not empty, the initial default value is based on // the human-readable form element value. @@ -73,7 +68,7 @@ Drupal.behaviors.machineName = { // If it is editable, append an edit link. var $link = $('' + Drupal.t('Edit') + '') .click(function () { - $wrapper.children().show(); + $wrapper.show(); $target.focus(); $suffix.hide(); $source.unbind('.machineName'); diff --git a/core/modules/field_ui/field_ui.admin.inc b/core/modules/field_ui/field_ui.admin.inc index 20b7fa6..0764956 100644 --- a/core/modules/field_ui/field_ui.admin.inc +++ b/core/modules/field_ui/field_ui.admin.inc @@ -517,10 +517,9 @@ function field_ui_field_overview_form($form, &$form_state, $entity_type, $bundle // This field should stay LTR even for RTL languages. '#field_prefix' => 'field_', '#field_suffix' => '', - '#attributes' => array('dir' => 'ltr'), '#size' => 10, + '#description' => t('A unique machine-readable name.'), '#maxlength' => 32 - drupal_strlen('field_'), - '#description' => t('Machine name'), '#prefix' => '