Skip to content
Snippets Groups Projects
Commit 2a3e3b2f authored by Dries Buytaert's avatar Dries Buytaert
Browse files

- Patch #53480 by chx et al: clean and harden form_builder for various types of posted elements.

parent 7d9217fc
No related branches found
No related tags found
No related merge requests found
......@@ -323,12 +323,24 @@ function form_builder($form_id, $form) {
$form['#ref'] = &$ref;
if (!isset($form['#value'])) {
if ($posted) {
if (isset($edit)) {
$form['#value'] = $edit; // normal element
$form['#needs_validation'] = TRUE;
switch ($form['#type']) {
case 'checkbox':
$form['#value'] = isset($edit) ? $form['#return_value'] : 0;
break;
case 'select':
$form['#value'] = isset($edit) ? $edit : array();
break;
case 'textfield':
if (isset($edit)) {
$form['#value'] = str_replace(array("\r", "\n"), '', $edit);
}
break;
default:
if (isset($edit)) {
$form['#value'] = $edit;
}
}
elseif (isset($form['#return_value'])) {
$form['#value'] = '0'; // checkbox unchecked
if (isset($form['#value'])) {
$form['#needs_validation'] = TRUE;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment