From bbfc566c7f70d948672296b0d72d339af769f366 Mon Sep 17 00:00:00 2001 From: webchick Date: Tue, 23 Oct 2012 19:28:41 -0700 Subject: [PATCH] Issue #1820834 by sun: Change #type machine_name() default 'source' element to 'label'. --- core/includes/form.inc | 5 ++--- core/modules/config/tests/config_test/config_test.module | 2 -- .../contact/lib/Drupal/contact/CategoryFormController.php | 1 - core/modules/filter/filter.admin.inc | 1 + core/modules/image/image.admin.inc | 2 -- core/modules/node/content_types.inc | 1 + .../lib/Drupal/taxonomy/VocabularyFormController.php | 1 + 7 files changed, 5 insertions(+), 8 deletions(-) diff --git a/core/includes/form.inc b/core/includes/form.inc index 86264d2b38e..6956f042704 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -3537,7 +3537,7 @@ function form_process_tableselect($element) { * value differs from the element's #default_value. * - source: (optional) The #array_parents of the form element containing * the human-readable name (i.e., as contained in the $form structure) to - * use as source for the machine name. Defaults to array('name'). + * use as source for the machine name. Defaults to array('label'). * - label: (optional) A text to display as label for the machine name value * after the human-readable name form element. Defaults to "Machine name". * - replace_pattern: (optional) A regular expression (without delimiters) @@ -3570,8 +3570,7 @@ function form_process_machine_name($element, &$form_state) { // 'source' only) would leave all other properties undefined, if the defaults // were defined in hook_element_info(). Therefore, we apply the defaults here. $element['#machine_name'] += array( - // @todo Use 'label' by default. - 'source' => array('name'), + 'source' => array('label'), 'target' => '#' . $element['#id'], 'label' => t('Machine name'), 'replace_pattern' => '[^a-z0-9_]+', diff --git a/core/modules/config/tests/config_test/config_test.module b/core/modules/config/tests/config_test/config_test.module index 44df4daadfe..3e1cbe95d73 100644 --- a/core/modules/config/tests/config_test/config_test.module +++ b/core/modules/config/tests/config_test/config_test.module @@ -214,8 +214,6 @@ function config_test_form($form, &$form_state, ConfigTest $config_test = NULL) { '#required' => TRUE, '#machine_name' => array( 'exists' => 'config_test_load', - // @todo Update form_process_machine_name() to use 'label' by default. - 'source' => array('label'), ), ); $form['style'] = array( diff --git a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php index 37a1aba5aa7..9a2f9bafef3 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php @@ -36,7 +36,6 @@ class CategoryFormController extends EntityFormController { '#default_value' => $category->id(), '#machine_name' => array( 'exists' => 'contact_category_load', - 'source' => array('label'), ), '#disabled' => !$category->isNew(), ); diff --git a/core/modules/filter/filter.admin.inc b/core/modules/filter/filter.admin.inc index 194a82c8691..4f56856a46e 100644 --- a/core/modules/filter/filter.admin.inc +++ b/core/modules/filter/filter.admin.inc @@ -181,6 +181,7 @@ function filter_admin_format_form($form, &$form_state, $format) { '#maxlength' => 255, '#machine_name' => array( 'exists' => 'filter_format_exists', + 'source' => array('name'), ), '#disabled' => !empty($format->format), ); diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 478f215cd6b..ca55227141b 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -59,7 +59,6 @@ function image_style_form($form, &$form_state, $style) { '#default_value' => $style->id(), '#machine_name' => array( 'exists' => 'image_style_load', - 'source' => array('label'), ), '#required' => TRUE, ); @@ -246,7 +245,6 @@ function image_style_add_form($form, &$form_state) { '#type' => 'machine_name', '#machine_name' => array( 'exists' => 'image_style_load', - 'source' => array('label'), ), '#default_value' => '', '#required' => TRUE, diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc index 34501961643..a7faa599473 100644 --- a/core/modules/node/content_types.inc +++ b/core/modules/node/content_types.inc @@ -132,6 +132,7 @@ function node_type_form($form, &$form_state, $type = NULL) { '#disabled' => $type->locked, '#machine_name' => array( 'exists' => 'node_type_load', + 'source' => array('name'), ), '#description' => t('A unique machine-readable name for this content type. It must only contain lowercase letters, numbers, and underscores. This name will be used for constructing the URL of the %node-add page, in which underscores will be converted into hyphens.', array( '%node-add' => t('Add new content'), diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php index b791d8bbcfb..f6e51105060 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php @@ -37,6 +37,7 @@ class VocabularyFormController extends EntityFormController { '#maxlength' => 255, '#machine_name' => array( 'exists' => 'taxonomy_vocabulary_machine_name_load', + 'source' => array('name'), ), ); $form['description'] = array(