From f8534504b3e14dbc76d7287a2e03ab948e9be87a Mon Sep 17 00:00:00 2001 From: Dries Buytaert <dries@buytaert.net> Date: Sun, 27 Aug 2006 12:54:01 +0000 Subject: [PATCH] - Patch #80895 by webchick et al: make it easier to disable form elements. --- includes/form.inc | 4 ++++ modules/comment/comment.module | 2 +- modules/filter/filter.module | 2 +- modules/system/system.module | 4 ++-- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/form.inc b/includes/form.inc index 9e63aa900935..d0a8e5dbe082 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -556,6 +556,10 @@ function form_builder($form_id, $form) { $form['#id'] = 'edit-' . implode('-', $form['#parents']); } + if (isset($form['#disabled']) && $form['#disabled']) { + $form['#attributes']['disabled'] = 'disabled'; + } + if (!isset($form['#value']) && !array_key_exists('#value', $form)) { if (($form['#programmed']) || ((!isset($form['#access']) || $form['#access']) && isset($_POST['edit']) && ($_POST['edit']['form_id'] == $form_id))) { $edit = $form['#post']['edit']; diff --git a/modules/comment/comment.module b/modules/comment/comment.module index 4bb83df6c385..86af8f0b17b6 100644 --- a/modules/comment/comment.module +++ b/modules/comment/comment.module @@ -438,7 +438,7 @@ function comment_admin_settings() { '#description' => t('This option is enabled when anonymous users have permission to post comments on the <a href="@url">permissions page</a>.', array('@url' => url('admin/user/access'))), ); if (!user_access('post comments', user_load(array('uid' => 0)))) { - $form['posting_settings']['comment_anonymous']['#attributes'] = array('disabled' => 'disabled'); + $form['posting_settings']['comment_anonymous']['#disabled'] = TRUE; } $form['posting_settings']['comment_subject_field'] = array( diff --git a/modules/filter/filter.module b/modules/filter/filter.module index c310ba51e4b9..ba0628a06f17 100644 --- a/modules/filter/filter.module +++ b/modules/filter/filter.module @@ -425,7 +425,7 @@ function filter_admin_format_form($format = NULL) { '#default_value' => ($default || $checked), ); if ($default) { - $form['roles'][$rid]['#attributes'] = array('disabled' => 'disabled'); + $form['roles'][$rid]['#disabled'] = TRUE; } } // Table with filters diff --git a/modules/system/system.module b/modules/system/system.module index 045d09b5e15f..b9dfe9b13861 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -538,7 +538,7 @@ function system_clean_url_settings() { if (!variable_get('clean_url', 0)) { if (strpos(request_uri(), '?q=') !== FALSE) { $form['clean_url']['#description'] .= t(' Before enabling clean URLs, you must perform a test to determine if your server is properly configured. If you are able to see this page again after clicking the "Run the clean URL test" link, the test has succeeded and the radio buttons above will be available. If instead you are directed to a "Page not found" error, you will need to change the configuration of your server. The <a href="@handbook">handbook page on Clean URLs</a> has additional troubleshooting information. !run-test', array('@handbook' => 'http://drupal.org/node/15365', '!run-test' => '<a href ="'. base_path() . 'admin/settings/clean-urls">'. t('Run the clean URL test') .'</a>')); - $form['clean_url']['#attributes'] = array('disabled' => 'disabled'); + $form['clean_url']['#disabled'] = TRUE; } else { $form['clean_url']['#description'] .= t(' You have successfully demonstrated that clean URLs work on your server. You are welcome to enable/disable them as you wish.'); @@ -1413,7 +1413,7 @@ function system_theme_settings($key = '') { // disable search box if search.module is disabled $form['theme_settings'][$name] = array('#type' => 'checkbox', '#title' => $title, '#default_value' => $settings[$name]); if (isset($disabled[$name])) { - $form['theme_settings'][$name]['#attributes'] = array('disabled' => 'disabled'); + $form['theme_settings'][$name]['#disabled'] = TRUE; } } } -- GitLab