summaryrefslogtreecommitdiff
path: root/modules/taxonomy
diff options
context:
space:
mode:
Diffstat (limited to 'modules/taxonomy')
-rw-r--r--modules/taxonomy/taxonomy.admin.inc53
-rw-r--r--modules/taxonomy/taxonomy.test2
2 files changed, 5 insertions, 50 deletions
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index 7b81db26d..7d314634a 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -137,30 +137,13 @@ function taxonomy_form_vocabulary($form, &$form_state, $edit = array()) {
'#default_value' => $vocabulary->name,
'#maxlength' => 255,
'#required' => TRUE,
- '#field_suffix' => ' <small id="edit-name-suffix">&nbsp;</small>',
- );
- $js_settings = array(
- 'type' => 'setting',
- 'data' => array(
- 'machineReadableValue' => array(
- 'name' => array(
- 'text' => t('Machine name'),
- 'target' => 'machine-name',
- 'searchPattern' => '[^a-z0-9]+',
- 'replaceToken' => '_',
- ),
- ),
- ),
);
$form['machine_name'] = array(
- '#type' => 'textfield',
- '#title' => t('Machine-readable name'),
+ '#type' => 'machine_name',
'#default_value' => $vocabulary->machine_name,
- '#maxlength' => 255,
- '#description' => t('The unique machine-readable name for this vocabulary, used for theme templates. Can only contain lowercase letters, numbers, and underscores.'),
- '#required' => TRUE,
- '#attached' => array(
- 'js' => array(drupal_get_path('module', 'system') . '/system.js', $js_settings),
+ '#maxlength' => 21,
+ '#machine_name' => array(
+ 'exists' => 'taxonomy_vocabulary_machine_name_load',
),
);
$form['old_machine_name'] = array(
@@ -190,34 +173,6 @@ function taxonomy_form_vocabulary($form, &$form_state, $edit = array()) {
}
/**
- * Validation handler for the vocabulary form.
- *
- * @see taxonomy_form_vocabulary()
- */
-function taxonomy_form_vocabulary_validate($form, &$form_state) {
- if ($form_state['clicked_button']['#value'] != t('Delete') && isset($form_state['values']['machine_name'])) {
-
- // Restrict machine names to appropriate characters.
- $machine_name = $form_state['values']['machine_name'];
- if (!preg_match('!^[a-z0-9_]+$!', $form_state['values']['machine_name'])) {
- form_set_error('machine_name', t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
- }
- // Restrict machine names to 21 characters to avoid exceeding the limit
- // for field names.
- if (drupal_strlen($machine_name) > 21) {
- form_set_error('machine_name', t('The machine-readable name must not exceed 21 characters.'));
- }
-
- // Do not allow duplicate machine names.
- $vocabularies = taxonomy_get_vocabularies();
- foreach ($vocabularies as $vocabulary) {
- if ($machine_name == $vocabulary->machine_name && (!isset($form_state['values']['vid']) || $vocabulary->vid != $form_state['values']['vid'])) {
- form_set_error('machine_name', t('This machine-readable name is already in use by another vocabulary and must be unique.'));
- }
- }
- }
-}
-/**
* Accept the form submission for a vocabulary and save the results.
*/
function taxonomy_form_vocabulary_submit($form, &$form_state) {
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 174e258ac..0a08c1bde 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -92,7 +92,7 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase {
// Try to submit a vocabulary with a duplicate machine name.
$edit['machine_name'] = $machine_name;
$this->drupalPost('admin/structure/taxonomy/add', $edit, t('Save'));
- $this->assertText(t('This machine-readable name is already in use by another vocabulary and must be unique.'), t('Duplicate machine name validation was successful'));
+ $this->assertText(t('The machine-readable name is already in use. It must be unique.'));
// Try to submit an invalid machine name.
$edit['machine_name'] = '!&^%';