From fed7e664de5ea6965a024f9e9b9c4cb45d2efddf Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 15 May 2004 15:42:47 +0000 Subject: [PATCH] - Patch #6682 by jhriggs: added form_checkboxes(), much like form_radios() and updated some modules to take advantage of it. --- includes/common.inc | 13 +++++++++++++ modules/taxonomy.module | 2 +- modules/taxonomy/taxonomy.module | 2 +- modules/user.module | 2 +- modules/user/user.module | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index d4e8d6b458f..71e4da38cb4 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -1034,6 +1034,19 @@ function form_checkbox($title, $name, $value = 1, $checked = 0, $description = N return form_hidden($name, 0) . theme('form_element', NULL, $element, $description, $required); } +function form_checkboxes($title, $name, $values, $options, $description = NULL, $required = FALSE) { + if (count($options) > 0) { + if (!isset($values)) { + $values = array(); + } + $choices = ''; + foreach ($options as $key => $choice) { + $choices .= "
"; + } + return theme('form_element', $title, $choices, $description, $required); + } +} + function form_textfield($title, $name, $value, $size, $maxlength, $description = NULL, $attributes = NULL, $required = FALSE) { $size = $size ? " size=\"$size\"" : ""; return theme("form_element", $title, "", $description, $name, $required); diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 0d9050950ca..99b3460f975 100644 --- a/modules/taxonomy.module +++ b/modules/taxonomy.module @@ -71,7 +71,7 @@ function taxonomy_form_vocabulary($edit = array()) { $form .= form_textfield(t("Vocabulary name"), "name", $edit["name"], 50, 64, t("Required") .". ". t("The name for this vocabulary. Example: 'Topic'") ."."); $form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") .". ". t("Description of the vocabulary, can be used by modules.")); $form .= form_textfield(t("Help text"), "help", $edit["help"], 50, 255, t("Optional") .". ". t("Instructions to present to the user when choosing a term.") ."."); - $form .= form_select(t("Types"), "nodes", explode(",", $edit["nodes"]), $nodetypes, t("Required") .". ". t("A list of node types you want to associate this vocabulary with."), "", 1); + $form .= form_checkboxes(t("Types"), "nodes", explode(",", $edit["nodes"]), $nodetypes, t("Required") .". ". t("A list of node types you want to associate this vocabulary with.")); $form .= form_checkbox(t("Related terms"), "relations", 1, $edit["relations"], t("Optional") .". ". t("Allows related terms in this vocabulary.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "related-terms")))); $form .= form_radios(t("Hierarchy"), "hierarchy", $edit["hierarchy"], array(t("Disabled"), t("Single"), t("Multiple")), t("Optional") .". ". t("Allows a tree-like hierarchy between terms of this vocabulary.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "hierarchy"))), "", 0); $form .= form_checkbox(t("Multiple select"), "multiple", 1, $edit["multiple"], t("Optional") .". ". t("Allows nodes to have more than one term in this vocabulary.")); diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 0d9050950ca..99b3460f975 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -71,7 +71,7 @@ function taxonomy_form_vocabulary($edit = array()) { $form .= form_textfield(t("Vocabulary name"), "name", $edit["name"], 50, 64, t("Required") .". ". t("The name for this vocabulary. Example: 'Topic'") ."."); $form .= form_textarea(t("Description"), "description", $edit["description"], 60, 5, t("Optional") .". ". t("Description of the vocabulary, can be used by modules.")); $form .= form_textfield(t("Help text"), "help", $edit["help"], 50, 255, t("Optional") .". ". t("Instructions to present to the user when choosing a term.") ."."); - $form .= form_select(t("Types"), "nodes", explode(",", $edit["nodes"]), $nodetypes, t("Required") .". ". t("A list of node types you want to associate this vocabulary with."), "", 1); + $form .= form_checkboxes(t("Types"), "nodes", explode(",", $edit["nodes"]), $nodetypes, t("Required") .". ". t("A list of node types you want to associate this vocabulary with.")); $form .= form_checkbox(t("Related terms"), "relations", 1, $edit["relations"], t("Optional") .". ". t("Allows related terms in this vocabulary.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "related-terms")))); $form .= form_radios(t("Hierarchy"), "hierarchy", $edit["hierarchy"], array(t("Disabled"), t("Single"), t("Multiple")), t("Optional") .". ". t("Allows a tree-like hierarchy between terms of this vocabulary.", array("%help-url" => url("admin/taxonomy/help", NULL, NULL, "hierarchy"))), "", 0); $form .= form_checkbox(t("Multiple select"), "multiple", 1, $edit["multiple"], t("Optional") .". ". t("Allows nodes to have more than one term in this vocabulary.")); diff --git a/modules/user.module b/modules/user.module index 1d8a41f64e5..e6b6cd42c37 100644 --- a/modules/user.module +++ b/modules/user.module @@ -1665,7 +1665,7 @@ function user_admin_edit($edit = array()) { $group .= form_textfield(t("E-mail address"), "mail", $account->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.")); $group .= form_item(t("Password"), " ", t("Enter a new password twice if you want to change the current password for this user or leave it blank if you are happy with the current password.")); $group .= form_radios(t("Status"), "status", $account->status, array(t("Blocked"), t("Active"))); - $group .= form_select(t('Roles'), 'rid', array_keys($account->roles), user_roles(1), t("Select at least one role. The user receives the combined permissions of all of the selected roles."), 0, 1); + $group .= form_checkboxes(t('Roles'), 'rid', array_keys($account->roles), user_roles(1), t("Select at least one role. The user receives the combined permissions of all of the selected roles.")); $output = form_group(t('Account information'), $group); diff --git a/modules/user/user.module b/modules/user/user.module index 1d8a41f64e5..e6b6cd42c37 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -1665,7 +1665,7 @@ function user_admin_edit($edit = array()) { $group .= form_textfield(t("E-mail address"), "mail", $account->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.")); $group .= form_item(t("Password"), " ", t("Enter a new password twice if you want to change the current password for this user or leave it blank if you are happy with the current password.")); $group .= form_radios(t("Status"), "status", $account->status, array(t("Blocked"), t("Active"))); - $group .= form_select(t('Roles'), 'rid', array_keys($account->roles), user_roles(1), t("Select at least one role. The user receives the combined permissions of all of the selected roles."), 0, 1); + $group .= form_checkboxes(t('Roles'), 'rid', array_keys($account->roles), user_roles(1), t("Select at least one role. The user receives the combined permissions of all of the selected roles.")); $output = form_group(t('Account information'), $group);