Re: [vcl4php-developers] edit hidden value stuff
Brought to you by:
ttm
|
From: José L. S. <su...@qa...> - 2009-05-14 09:16:08
|
Gary escribió: > in stdctrls.inc.php in revision 216 , which says nothing about it, the > standard edit box got a bunch of _hidden and _hiddenvalue stuff added to it > which as far as I can tell does nothing but add a couple of pages of > functions (50 edits * 7 lines) to my browser source and also cause me a PIA > when I fill edits with info with js. > > As the edits worked fine before this change was made, I'm ready to just > remove that 'feature' but I thought I would ask why it was implemented > before I do. Check the init and preinit methods of the component, the problem that is fixed by that code, is when you place an Edit control (or any other control that updates it's state depending on POST information )inside a QWidget container with layers (like PageControl), when the form is submitted, you don't always get the right information on the post. For example: -Having a PageControl with two tabs and with an edit on each one -Placing a print_r($_POST) at the very top of the script -Adding a button outside of the page control to submit the form If you click on the button, you will get this: Array ( [Edit1_hidden] => 123454 [Edit2_hidden] => aaaaaaa [Button1] => Button1 [PageControl1_state] => [Edit1] => 123454 ) That is, no Edit2 value on the array, because the user has not switched to the second tab, the Edit2 post value is not being submitted, that's why an extra hiddenfield is required outside the pagecontrol, to keep that value for the subsequent requests. This is a general method, probably can be improved by trying to rely on the session value, but it's a way to ensure the right value is picked up, and also, there was login on the init method to update a possible datafield attached, so to reduce the possible impact of a bigger change, I opted by this method. As you say, you get 7 extra lines for each edit, so maybe this kind of code can be packed on a function where the Edit is a parameter, and even included on a separate .js to reduce the clutter. As always, your patches will be welcome. And you are right, that should be documented on the change log, my fault :-( Regards -- José León qadram software C/Juan Ramón Jiménez, 15 Entlo. 2 03203 Elche ALICANTE (SPAIN) T: +34 965 45 48 48 F: +34 965 45 48 48 M: +34 618 28 13 69 http://www.qadram.com |