Commit fd96728f authored by Dries's avatar Dries

- Second batch of form API fixes by chx.

parent 6f30f02c
......@@ -651,7 +651,7 @@ function theme_select($element) {
if (is_array($choice)) {
$select .= '<optgroup label="'. $key .'">';
foreach ($choice as $key => $choice) {
$select .= '<option value="'. $key .'"'. (is_array($elementp[value]) ? (in_array($key, $element[value]) ? ' selected="selected"' : '') : ($element[value] == $key ? ' selected="selected"' : '')) .'>'. check_plain($choice) .'</option>';
$select .= '<option value="'. $key .'"'. (is_array($element[value]) ? (in_array($key, $element[value]) ? ' selected="selected"' : '') : ($element[value] == $key ? ' selected="selected"' : '')) .'>'. check_plain($choice) .'</option>';
}
$select .= '</optgroup>';
}
......@@ -781,7 +781,8 @@ function expand_date($element) {
/**
* Roll out a single checkbox element to a list of checkboxes, using the options array as index.
* Roll out a single adios element
* to a list of radios, using the options array as index.
*/
function expand_radios($element) {
if (count($element[options]) > 0) {
......@@ -861,10 +862,7 @@ function expand_checkboxes($element) {
}
foreach ($element[options] as $key => $choice) {
if (!isset($element[$key])) {
$element[$key] = array(
type => 'checkbox', processed => TRUE, title => $choice, tree => TRUE,
value => in_array($key, $value), attributes => $element[attributes]
);
$element[$key] = array(type => 'checkbox', processed => TRUE, title => $choice, tree => TRUE, default_value => in_array($key, $value), attributes => $element[attributes]);
}
}
}
......
......@@ -829,10 +829,9 @@ function system_modules() {
}
/**
* Handle status checkboxes, including overriding the generated checkboxes for required modules.
*/
$form['status'] = array(type => 'checkboxes', default_value => $status, options => $options, tree => TRUE);
// Handle status checkboxes, including overriding the generated
// checkboxes for required modules.
$form['status'] = array(type => 'checkboxes', default_value => $status, options => $options, tree => TRUE);
$required = array('block', 'filter', 'system', 'user', 'watchdog');
foreach ($required as $require) {
$form['status'][$require] = array(type => 'hidden', value => 1, suffix => t('required'));
......@@ -879,11 +878,11 @@ function theme_system_modules($form) {
function system_modules_execute($form_id, $edit) {
db_query("update {system} set status = 0, throttle = 0 where type = 'module'");
db_query("UPDATE {system} SET status = 0, throttle = 0 WHERE type = 'module'");
foreach ($edit['status'] as $key => $choice) {
if ($choice) {
db_query("update {system} set status = 1 where type = 'module' and name = '%s'", $key);
db_query("UPDATE {system} SET status = 1 WHERE type = 'module' AND name = '%s'", $key);
}
}
......
......@@ -829,10 +829,9 @@ function system_modules() {
}
/**
* Handle status checkboxes, including overriding the generated checkboxes for required modules.
*/
$form['status'] = array(type => 'checkboxes', default_value => $status, options => $options, tree => TRUE);
// Handle status checkboxes, including overriding the generated
// checkboxes for required modules.
$form['status'] = array(type => 'checkboxes', default_value => $status, options => $options, tree => TRUE);
$required = array('block', 'filter', 'system', 'user', 'watchdog');
foreach ($required as $require) {
$form['status'][$require] = array(type => 'hidden', value => 1, suffix => t('required'));
......@@ -879,11 +878,11 @@ function theme_system_modules($form) {
function system_modules_execute($form_id, $edit) {
db_query("update {system} set status = 0, throttle = 0 where type = 'module'");
db_query("UPDATE {system} SET status = 0, throttle = 0 WHERE type = 'module'");
foreach ($edit['status'] as $key => $choice) {
if ($choice) {
db_query("update {system} set status = 1 where type = 'module' and name = '%s'", $key);
db_query("UPDATE {system} SET status = 1 WHERE type = 'module' AND name = '%s'", $key);
}
}
......
......@@ -517,8 +517,8 @@ function user_block($op = 'list', $delta = 0, $edit = array()) {
case 0:
// For usability's sake, avoid showing two login forms on one page.
if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {
$form['name'] = array(type => 'textfield', title => t('Username'), maxlength => 64, size => 15, required => TRUE);
$form['pass'] = array(type => 'password', title => t('Password'), maxlength => 64, size => 15, required => TRUE);
$form['name'] = array(type => 'textfield', title => t('Username'), maxlength => 64, size => 15);
$form['pass'] = array(type => 'password', title => t('Password'), maxlength => 64, size => 15);
$form['submit'] = array(type => 'submit', value => t('Log in'));
$output .= drupal_get_form('user_login_block', $form, 'user_login');
if (variable_get('user_register', 1)) {
......
......@@ -517,8 +517,8 @@ function user_block($op = 'list', $delta = 0, $edit = array()) {
case 0:
// For usability's sake, avoid showing two login forms on one page.
if (!$user->uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) {
$form['name'] = array(type => 'textfield', title => t('Username'), maxlength => 64, size => 15, required => TRUE);
$form['pass'] = array(type => 'password', title => t('Password'), maxlength => 64, size => 15, required => TRUE);
$form['name'] = array(type => 'textfield', title => t('Username'), maxlength => 64, size => 15);
$form['pass'] = array(type => 'password', title => t('Password'), maxlength => 64, size => 15);
$form['submit'] = array(type => 'submit', value => t('Log in'));
$output .= drupal_get_form('user_login_block', $form, 'user_login');
if (variable_get('user_register', 1)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment