diff options
author | Dries Buytaert <dries@buytaert.net> | 2010-10-13 13:43:21 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2010-10-13 13:43:21 +0000 |
commit | 284f2b11a48b893cbd13d5429ad68d207488e4e6 (patch) | |
tree | 84b9bd1672ec7d9f585c2e4019d2f1f3b508afe1 /modules/taxonomy/taxonomy.admin.inc | |
parent | 3e6b9b5ea35dfb32e3c30a4d012f67c1d268a570 (diff) | |
download | brdo-284f2b11a48b893cbd13d5429ad68d207488e4e6.tar.gz brdo-284f2b11a48b893cbd13d5429ad68d207488e4e6.tar.bz2 |
- Patch #902644 by sun, tobiasb: machine names are too hard to implement. Date types and menu names are not validated.
This patch fixes a bug, but is also a last minute clean-up that will help with better distribution support. We discussed this in http://drupal.org/node/933846.
Diffstat (limited to 'modules/taxonomy/taxonomy.admin.inc')
-rw-r--r-- | modules/taxonomy/taxonomy.admin.inc | 53 |
1 files changed, 4 insertions, 49 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"> </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) { |