summaryrefslogtreecommitdiff
path: root/includes/form.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-01-24 08:20:45 +0000
committerDries Buytaert <dries@buytaert.net>2006-01-24 08:20:45 +0000
commitb9f6b72a5877943e13d940e0705826d002ca1361 (patch)
tree7a5a2c26fdd2c856258f022ad2573425bb3c7274 /includes/form.inc
parentaf43886456ebd248b8972e3050e78009efe4f521 (diff)
downloadbrdo-b9f6b72a5877943e13d940e0705826d002ca1361.tar.gz
brdo-b9f6b72a5877943e13d940e0705826d002ca1361.tar.bz2
- Patch #45834 by jvandyk: removed forms API warnings.
Diffstat (limited to 'includes/form.inc')
-rw-r--r--includes/form.inc30
1 files changed, 20 insertions, 10 deletions
diff --git a/includes/form.inc b/includes/form.inc
index 021c76884..db6e53d39 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -21,6 +21,9 @@ function element_property($key) {
return $key[0] == '#';
}
+/**
+ * Get properties of a form tree element. Properties begin with '#'.
+ */
function element_properties($element) {
return array_filter(array_keys((array) $element), 'element_property');
}
@@ -32,6 +35,9 @@ function element_child($key) {
return $key[0] != '#';
}
+/**
+ * Get keys of a form tree element that are not properties (i.e., do not begin with '#').
+ */
function element_children($element) {
return array_filter(array_keys((array) $element), 'element_child');
}
@@ -253,7 +259,7 @@ function _form_builder($form_id, $form) {
$form += $info;
}
- if ($form['#input']) {
+ if (isset($form['#input']) && $form['#input']) {
if (!isset($form['#name'])) {
$form['#name'] = 'edit[' . implode('][', $form['#parents']) . ']';
}
@@ -287,7 +293,7 @@ function _form_builder($form_id, $form) {
}
}
}
- if (isset($form['#form_submitted'])) {
+ if (isset($form['#form_submitted']) && isset($_POST[$form['#name']])) {
if ($_POST[$form['#name']] == $form['#value']) {
$form_submitted = $form_submitted || $form['#form_submitted'];
}
@@ -308,7 +314,7 @@ function _form_builder($form_id, $form) {
// Set the $form_values key that gets passed to validate and submit.
// We call this after #process gets called so that #process has a
// chance to update #value if desired.
- if ($form['#input']) {
+ if (isset($form['#input']) && $form['#input']) {
$ref = $form['#value'];
}
@@ -334,7 +340,7 @@ function _form_builder($form_id, $form) {
$count++;
}
- if (function_exists($form['#after_build']) && !isset($form['#after_build_done'])) {
+ if (isset($form['#after_build']) && function_exists($form['#after_build']) && !isset($form['#after_build_done'])) {
$function = $form['#after_build'];
$form = $function($form, $form_values, $ref);
$form['#after_build_done'] = TRUE;
@@ -361,9 +367,9 @@ function form_render(&$elements) {
$content = '';
uasort($elements, "_form_sort");
- if (!$elements['#children']) {
+ if (!isset($elements['#children'])) {
/* render all the children using a theme function */
- if ($elements['#theme'] && !$elements['#theme_used']) {
+ if (isset($elements['#theme']) && !$elements['#theme_used']) {
$elements['#theme_used'] = TRUE;
$previous_type = $elements['#type'];
$elements['#type'] = 'markup';
@@ -382,13 +388,15 @@ function form_render(&$elements) {
}
/* Call the form element renderer */
- if (!$elements['#printed']) {
+ if (!isset($elements['#printed'])) {
$content = theme(($elements['#type']) ? $elements['#type']: 'markup', $elements);
$elements['#printed'] = TRUE;
}
if ($content) {
- return $elements['#prefix'] . $content . $elements['#suffix'];
+ $prefix = isset($elements['#prefix']) ? $elements['#prefix'] : '';
+ $suffix = isset($elements['#suffix']) ? $elements['#suffix'] : '';
+ return $prefix . $content . $suffix;
}
}
@@ -507,7 +515,7 @@ function form_select_options($element, $choices = NULL) {
*
* @param $element
* An associative array containing the properties of the element.
- * Properties used: attributes, title, description, children, collapsible, collapsed
+ * Properties used: attributes, title, value, description, children, collapsible, collapsed
* @return
* A themed HTML string representing the form item group.
*/
@@ -796,6 +804,8 @@ function theme_hidden($element) {
*/
function theme_textfield($element) {
$size = $element['#size'] ? ' size="' . $element['#size'] . '"' : '';
+ $class = '';
+ $extra = '';
if ($element['#autocomplete_path']) {
drupal_add_js('misc/autocomplete.js');
$class = ' form-autocomplete';
@@ -870,7 +880,7 @@ function theme_markup($element) {
function theme_password($element) {
$size = $element['#size'] ? ' size="'. $element['#size'] .'" ' : '';
- $output = '<input type="password" maxlength="'. $element['#maxlength'] .'" class="'. _form_get_class("form-text $class", $element['#required'], form_get_error($element)) .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. $size . drupal_attributes($element['#attributes']) .' />';
+ $output = '<input type="password" maxlength="'. $element['#maxlength'] .'" class="'. _form_get_class('form-text', $element['#required'], form_get_error($element)) .'" name="'. $element['#name'] .'" id="'. $element['#id'] .'" '. $size . drupal_attributes($element['#attributes']) .' />';
return theme('form_element', $element['#title'], $output, $element['#description'], $element['#id'], $element['#required'], form_get_error($element));
}