- Updated documentation, small bug fix and small improvements to the <label>

tags.

  To be discussed and investigated: when a form element has no title an empty
  <label> tag will be emitted (eg. "remember me" checkbox).  This doesn't make
  sense but is our best option for now.
4.4.x
Dries Buytaert 2003-12-22 15:38:07 +00:00
parent 8f226513b4
commit 770174b299
4 changed files with 12 additions and 5 deletions

View File

@ -764,10 +764,10 @@ function form_select($title, $name, $value, $options, $description = NULL, $extr
function form_radios($title, $name, $value, $options, $description = NULL) {
if (count($options) > 0) {
foreach ($options as $key=>$choice) {
foreach ($options as $key => $choice) {
$output .= form_radio($choice, $name, $key, ($key == $value));
}
return theme("form_element", $title, $output, $description);
return theme("form_element", $title, $output, $description, $name);
}
}

View File

@ -274,6 +274,7 @@ function theme_node($node, $main = 0, $page = 0) {
* @param $title the form element's title
* @param $value the form element's data
* @param $description the form element's description or explanation
* @param $id the form element's ID used by the &lt;label&gt; tag
*
* @return a string containing the @a node output.
*/
@ -288,12 +289,18 @@ function theme_form_element($title, $value, $description = NULL, $id = NULL) {
$title = "<label>$title:</label><br />";
}
}
else {
if ($id) {
$title = "<label for=\"$id\"></label>";
// TODO: does this make sense to do?
}
}
if ($description) {
$description = "<div class=\"description\">$description</div>";
}
return "<div class=\"form-item\">$title $value $description</div>\n";
return "<div class=\"form-item\">". $title . $value . $description ."</div>\n";
}
/**

View File

@ -675,7 +675,7 @@ function user_login($edit = array(), $msg = "") {
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64, t("Enter your %s username.", array("%s" => variable_get("site_name", "local"))));
}
$output .= form_password(t("Password"), "pass", $pass, 30, 64, t("Enter the password that accompanies your username."));
$output .= form_checkbox(t("Remember me"), "remember_me", 1, 0, 0);
$output .= form_checkbox(t("Remember me"), "remember_me");
$output .= form_submit(t("Log in"));
$items[] = l(t("Request new password"), "user/password");
if (variable_get("user_register", 1)) {

View File

@ -675,7 +675,7 @@ function user_login($edit = array(), $msg = "") {
$output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64, t("Enter your %s username.", array("%s" => variable_get("site_name", "local"))));
}
$output .= form_password(t("Password"), "pass", $pass, 30, 64, t("Enter the password that accompanies your username."));
$output .= form_checkbox(t("Remember me"), "remember_me", 1, 0, 0);
$output .= form_checkbox(t("Remember me"), "remember_me");
$output .= form_submit(t("Log in"));
$items[] = l(t("Request new password"), "user/password");
if (variable_get("user_register", 1)) {