|
Main sidebar
|
PITS /
01078Summary: Fields reloaded on error do not return to user entered values.
Created: 2009-03-01 21:04
Status: Closed (resolution provided)
Category: Bug
From: DaveG
Assigned:
Priority: 4
Version: 2.2
OS:
Description: 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. Resolution: Use both 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); Thanks for opening a PITS entry. I have read your message in the list but it is wise to have it in PITS too, for the record. I have this on my priority todo list, I just need to find some time to create some working forms and test the thing, hopefully in the next couple of days. --Petko I replied to your message in the mailing list [1], being unable to reproduce the bug. If the SVN version does have the bug, we'll investigate further. Petko March 11, 2009, at 04:21 PM ResolutionThe problem was that two separate lines were used to define defaults, which caused a conflict: (:input pmform target="djg-test":)\ (:input default source=DaveG.FormsTest-Data:) (:input default request=1:) The solution is to either use both request=1 and source=Page in the same 'input default' line: (:input default source=DaveG.FormsTest-Data request=1:) or place the |