diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-05-15 15:42:47 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-05-15 15:42:47 +0000 |
commit | fed7e664de5ea6965a024f9e9b9c4cb45d2efddf (patch) | |
tree | 7ed5d45a05b28594efd835a5b0e49ed60c7e5eca | |
parent | e1447f9b5a29dc7e87270bf53050845fe57367d8 (diff) | |
download | brdo-fed7e664de5ea6965a024f9e9b9c4cb45d2efddf.tar.gz brdo-fed7e664de5ea6965a024f9e9b9c4cb45d2efddf.tar.bz2 |
- Patch #6682 by jhriggs: added form_checkboxes(), much like form_radios()
and updated some modules to take advantage of it.
-rw-r--r-- | includes/common.inc | 13 | ||||
-rw-r--r-- | modules/taxonomy.module | 2 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 2 | ||||
-rw-r--r-- | modules/user.module | 2 | ||||
-rw-r--r-- | modules/user/user.module | 2 |
5 files changed, 17 insertions, 4 deletions
diff --git a/includes/common.inc b/includes/common.inc index d4e8d6b45..71e4da38c 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 .= "<label class=\"option\"><input type=\"checkbox\" class=\"form-checkbox\" name=\"edit[$name][]\" value=\"$key\"". (in_array($key, $values) ? " checked=\"checked\"" : "") ." /> $choice</label><br />"; + } + 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, "<input type=\"text\" maxlength=\"$maxlength\" class=\"form-text\" name=\"edit[$name]\" id=\"$name\"$size value=\"". check_form($value) ."\"". drupal_attributes($attributes) ." />", $description, $name, $required); diff --git a/modules/taxonomy.module b/modules/taxonomy.module index 0d9050950..99b3460f9 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 <a href=\"%help-url\">related terms</a> 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 href=\"%help-url\">a tree-like hierarchy</a> 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 0d9050950..99b3460f9 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 <a href=\"%help-url\">related terms</a> 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 href=\"%help-url\">a tree-like hierarchy</a> 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 1d8a41f64..e6b6cd42c 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"), "<input type=\"password\" name=\"edit[pass1]\" size=\"12\" maxlength=\"24\" /> <input type=\"password\" name=\"edit[pass2]\" size=\"12\" maxlength=\"24\" />", 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 1d8a41f64..e6b6cd42c 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"), "<input type=\"password\" name=\"edit[pass1]\" size=\"12\" maxlength=\"24\" /> <input type=\"password\" name=\"edit[pass2]\" size=\"12\" maxlength=\"24\" />", 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); |