[pmwiki-devel] fix: forms.php -- select list default on reload
DaveG
pmwiki at solidgone.com
Fri Feb 20 09:09:40 CST 2009
When the form reads values from a source, and is being reloaded due to
an entry error, the user values are over-ridden by the values in the
source file. Thus, select lists return to their original source file
values, rather than retaining the values selected by the user.
This is the fix for that:
Move this block:
if (@$args['request']) {
$req = array_merge($_GET, $_POST);
foreach($req as $k => $v){
if (!isset($InputValues[$k]))
$InputValues[$k] = htmlspecialchars(stripmagic($v), ENT_NOQUOTES);
}
}
Below the "if ($source) {" block.
Change the block to read override the source values (isset rather than
!isset):
if (@$args['request']) {
$req = array_merge($_GET, $_POST);
foreach($req as $k => $v){
if (isset($InputValues[$k]))
$InputValues[$k] = htmlspecialchars(stripmagic($v), ENT_NOQUOTES);
}
}
Patch file below.
Left file: Original forms.php
Right file: Modified forms.php
165,170c165
< if (@$args['request']) {
< $req = array_merge($_GET, $_POST);
< foreach($req as $k => $v)
< if (!isset($InputValues[$k]))
< $InputValues[$k] = htmlspecialchars(stripmagic($v), ENT_NOQUOTES);
< }
---
>
181a177,183
> }
> }
> if (@$args['request']) {
> $req = array_merge($_GET, $_POST);
> foreach($req as $k => $v){
> if (isset($InputValues[$k]))
> $InputValues[$k] = htmlspecialchars(stripmagic($v),
ENT_NOQUOTES);
~ ~ Dave
More information about the pmwiki-devel
mailing list