6.0.0-beta1
7/31/25

[#4083] preserveVarByPost, hidden value: output not within form tags
Summary preserveVarByPost, hidden value: output not within form tags
Queue Horde Framework Packages
Queue Version HEAD
Type Enhancement
State Resolved
Priority 1. Low
Owners
Requester thomas (at) gelf (dot) net
Created 06/26/2006 (6975 days ago)
Due
Updated 11/19/2006 (6829 days ago)
Assigned
Resolved 11/19/2006 (6829 days ago)
Milestone
Patch No

History
11/19/2006 11:50:29 PM Chuck Hagenbuch Comment #8
State ⇒ Resolved
Reply to this comment
Oops, wrong "R" state.
11/19/2006 11:49:49 PM Chuck Hagenbuch Comment #7
State ⇒ Rejected
Reply to this comment
Incubator Horde_Form will not do this (it's hacked up locally at the moment).
06/30/2006 10:33:16 PM thomas (at) gelf (dot) net Comment #6 Reply to this comment
ACK :-)




06/30/2006 06:37:46 PM Chuck Hagenbuch Comment #5
State ⇒ Accepted
Reply to this comment
I still don't think it's a bug, but you've convinced me that it should 
be refactored. I'm adding it to the list of things that should be 
taken care of with the incubator Horde_Form rewrite.
06/29/2006 06:56:05 PM thomas (at) gelf (dot) net Comment #4 Reply to this comment
Chuck: please change this ticket back from "Enhancement" to "Bug" - or just

tell me that I'm talking bullshit and close it :-)



Cheers,

Thomas Gelf
06/26/2006 10:42:36 PM thomas (at) gelf (dot) net Comment #3 Reply to this comment
Hehe...



- I wrote some kind of very tricky wizard with lots of subforms and more than

   one different ways of passing through the form

- time ago I did such things like in whups/ticket/create.php - but such a form

   isn't fun that way

- I wrote a "XyWizardStep extends Horde_Form" class

- and many "XyWizardStep_ChooseWhateverStep extends XyWizardStep"

   classes

- I didn't call _preserveVarByPost() directly but have been calling preserve()

- there is finally one "XyWizard extends Horde_Form" class handling all

   the "business logic", finding out what path to take through the forms,

   running validations, navigating fore- and backward through the single

   steps and finally storing the whole big thing



My problem: simply calling $form->preserve($vars) is useless - in my case

it puts the hidden fields required for preserving vars in front of the whole

html code because of the line in _preserveVarByPost() - mentioned

before.



I helped myself by "overwriting" addVariable() in my XyWizardStep class.

My addVariable() function adds a pointer to every added var to an array

named "_preserve_vars" - and a "getVarsToPreserve()" function gives me

the possibility to walk through all vars in all Inactive single forms, 
allowing

me to add each of them as a hidden var to the last (currently active) form

step.



I consider this a bug - preserve() is a public function - and it shouldn't be

up to the user / coder to find out that the function behaves only correct

if you manually open and close form tags before / after calling preserve().



IMO preserve() should add all vars that should be preserved to an array,

the rendering process should then take care of writing out the hidden

input fields.



Cheers,

Thomas Gelf
06/26/2006 10:08:19 PM Chuck Hagenbuch Comment #2
Type ⇒ Enhancement
State ⇒ Feedback
Priority ⇒ 1. Low
Reply to this comment
How is this a bug? What do you want it to do instead? You aren't 
seriously calling a private method randomly from your own code, are you?
06/26/2006 09:40:05 PM thomas (at) gelf (dot) net Comment #1
Priority ⇒ 1. Low
Type ⇒ Bug
Summary ⇒ preserveVarByPost, hidden value: output not within form tags
Queue ⇒ Horde Framework Packages
State ⇒ Unconfirmed
Reply to this comment
   _preserveVarByPost() immediately outputs hidden form fields by:



           printf('<input type="hidden" name="%s" value="%s" />' . "\n",

                    $varname,

                    $value);



Is there some good reason for doing so? This works when you're rendering

your form step by step (like whups/ticket/create.php) but otherwise makes no

sense and is kinda confusing...



Regards,

Thomas Gelf

Saved Queries