mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-07 10:41:40 +09:00
issue 1607 restore select value when validate error
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@10344 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
916965a607
commit
bd18f8661c
1 changed files with 20 additions and 0 deletions
|
|
@ -117,6 +117,7 @@ class HTMLDisplayHandler {
|
|||
$keys = '('.implode('|', $keys).')';
|
||||
|
||||
$output = preg_replace_callback('@(<input)([^>]*?)\sname="'.$keys.'"([^>]*?)/?>@is', array(&$this, '_preserveValue'), $output);
|
||||
$output = preg_replace_callback('@<select[^>]*\sname="'.$keys.'".+</select>@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('@<select.*?>@is', $match[0], $mm);
|
||||
|
||||
preg_match_all('@<option[^>]*\svalue="([^"]*)".+</option>@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]).'</select>';
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief add html style code extracted from html body to Context, which will be
|
||||
* printed inside <header></header> later.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue