diff --git a/classes/display/HTMLDisplayHandler.php b/classes/display/HTMLDisplayHandler.php index 60c9cb703..9609240ec 100644 --- a/classes/display/HTMLDisplayHandler.php +++ b/classes/display/HTMLDisplayHandler.php @@ -117,6 +117,7 @@ class HTMLDisplayHandler { $keys = '('.implode('|', $keys).')'; $output = preg_replace_callback('@(]*?)\sname="'.$keys.'"([^>]*?)/?>@is', array(&$this, '_preserveValue'), $output); + $output = preg_replace_callback('@]*\sname="'.$keys.'".+@isU', array(&$this, '_preserveSelectValue'), $output); } if(__DEBUG__==3) $GLOBALS['__trans_content_elapsed__'] = getMicroTime()-$start; @@ -179,6 +180,25 @@ class HTMLDisplayHandler { return $str.' />'; } + function _preserveSelectValue($match) + { + $INPUT_ERROR = Context::get('INPUT_ERROR'); + preg_replace('@\sselected(="[^"]*?")?@', ' ', $match[0]); + preg_match('@@is', $match[0], $mm); + + preg_match_all('@]*\svalue="([^"]*)".+@isU', $match[0], $m); + + $key = array_search($INPUT_ERROR[$match[1]], $m[1]); + if($key === FALSE) + { + return $match[0]; + } + + $m[0][$key] = preg_replace('@(\svalue=".*?")@is', '$1 selected="selected"', $m[0][$key]); + + return $mm[0].implode('', $m[0]).''; + } + /** * @brief add html style code extracted from html body to Context, which will be * printed inside
later.