Commit c7c9b57e authored by Gerhard Killesreiter's avatar Gerhard Killesreiter

#53967, form_builder checkbox/textfield/validation stuff, patch by hunmonk and chx

parent 07fe4198
......@@ -325,14 +325,16 @@ function form_builder($form_id, $form) {
if ($posted) {
switch ($form['#type']) {
case 'checkbox':
$form['#value'] = isset($edit) ? $form['#return_value'] : 0;
$form['#value'] = !empty($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);
// Equate $edit to the form value to ensure it's marked for validation
$edit = str_replace(array("\r", "\n"), '', $edit);
$form['#value'] = $edit;
}
break;
default:
......@@ -340,7 +342,8 @@ function form_builder($form_id, $form) {
$form['#value'] = $edit;
}
}
if (isset($form['#value'])) {
// Mark all posted values for validation
if (isset($form['#value']) && $form['#value'] === $edit) {
$form['#needs_validation'] = TRUE;
}
}
......
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