From da1d11935d3e25ce78af5b3621d36bc5422afb50 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 9 Feb 2006 07:34:16 +0000 Subject: [PATCH] - Patch #45821 by jvandyk: improved 'illegcal choice in .' messages --- includes/form.inc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/form.inc b/includes/form.inc index 9bce60738c1..66159313f5f 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -158,7 +158,6 @@ function _form_validate($elements, $form_id = NULL) { // Add legal choice check if element has #options. Can be skipped, but then you must validate your own element. if (isset($elements['#options']) && isset($elements['#value']) && !isset($elements['#DANGEROUS_SKIP_CHECK'])) { - $message = t('Illegal choice in %title.', array('%title' => theme('placeholder', $elements['#title']))); if ($elements['#type'] == 'select') { $options = form_options_flatten($elements['#options']); } @@ -169,12 +168,14 @@ function _form_validate($elements, $form_id = NULL) { $value = $elements['#type'] == 'checkboxes' ? array_keys(array_filter($elements['#value'])) : $elements['#value']; foreach ($value as $v) { if (!isset($options[$v])) { - form_error($elements, $message); + form_error($elements, t('An illegal choice has been detected. Please contact the site administrator.')); + watchdog('form', t('Illegal choice %choice in %name element.', array('%choice' => theme('placeholder', check_plain($v)), '%name' => theme_placeholder(empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'])), WATCHDOG_ERROR)); } } } elseif (!isset($options[$elements['#value']])) { - form_error($elements, $message); + form_error($elements, t('An illegal choice has been detected. Please contact the site administrator.')); + watchdog('form', t('Illegal choice %choice in %name element.', array('%choice' => theme_placeholder(check_plain($v)), '%name' => theme('placeholder', empty($elements['#title']) ? $elements['#parents'][0] : $elements['#title'])), WATCHDOG_ERROR)); } }