PHP Classes

Presenting a conformation screen...

Recommend this page to a friend!

      PHP Forms Class with HTML Generator and JavaScript Validation  >  PHP Forms Class with HTML Generator and JavaScript Validation package blog  >  How to Show Google Ma...  >  All threads  >  Presenting a conformation screen...  >  (Un) Subscribe thread alerts  
Subject:Presenting a conformation screen...
Summary:... before processing the form?
Messages:12
Author:ffff
Date:2007-07-08 18:18:17
Update:2007-07-11 04:38:36
 
  1 - 10   11 - 12  

  1. Presenting a conformation screen...   Reply   Report abuse  
Picture of ffff ffff - 2007-07-08 18:18:17
In most of the forms I build, I present the user with a confirmation screen so that he/she can confirm that the values are correct before processing the form. The confirmation screen would be a screen with the fields in "read only" mode, with two buttons: 'confirm', and 'go back and correct'.

I figured that I would need to use two valued for the "doit" variable:
1 = form submitted but not confirmed
2 = form submitted and confirmed

The only thing I an not figure out is that when the form is presented in the read only mode, if the form is submitted again with the confirm button all the valued would be lost! Normally, a confirm screen would have invisible fields with the same names as the fields so that if the form is submitted all the values are submitted too.

What would be the approach to do this using the forms validation class?

Do I have to actually create manually all the invisible fields? I think the class should create those fields automatically. and it should present some way of confirmation screen because that is very popular in forms.

  2. Re: Presenting a conformation screen...   Reply   Report abuse  
Picture of ffff ffff - 2007-07-08 18:58:26 - In reply to message 1 from ffff
Ok, I solved the problem. For anyone trying to do the same thing:

In the confirmation screen each individual form must be declared with the property "ReadOnly" and that way the values will be conserved using an invisible field.

If the readonly property is declares for ALL the form using $form->ReadOnly=1; then the values will NOT be conserved..


(maybe this should be changed I do not know...)

  3. Re: Presenting a conformation screen...   Reply   Report abuse  
Picture of Form Class Form Class - 2007-07-09 12:36:43 - In reply to message 2 from ffff
Manuel,

It would be ideal to offer a forms-class method such as:

SetInputsHidden( $inputs = array(), $skipInputTypes = array())

to render selective/all inputs (while skipping certain input-types) in hidden mode. It then becomes a snap to switch the input modes with fewer lines of code from the application.

Thoughts?

TIA

  4. Re: Presenting a conformation screen...   Reply   Report abuse  
Picture of Form Class Form Class - 2007-07-09 12:52:34 - In reply to message 3 from Form Class
By the way, we should be able to invoke the proposed SetInputsHidden(...) method in both - ReadOnly/write modes. The $skipInputTypes argument is important as we do not want to hide all the input types, though. I've already done this in a different way using $_POST and it necessitated use of $skipInputTypes to skip submits/buttons/etc and my method echoes a string of hidden inputs. That's all it takes for a confirmation screen's functionality.

Regards,

  5. Re: Presenting a conformation screen...   Reply   Report abuse  
Picture of Form Class Form Class - 2007-07-09 20:52:53 - In reply to message 4 from Form Class
My function does not use the input-level ReadOnly attribute; it just spits out/echoes a string of hidden inputs based on $_POST. There is no method for ReadOnly attribute and so we can have the new function named as:

SetReadOnly( $readOnly, $inputsAsHidden = false )

instead of SetInputsHidden(). If $readOnly is true and $inputsAsHidden is is true, all inputs could be rendered as hidden except submits/buttons (in addition to rendering the entire form as ReadOnly).

Regards,

  6. Re: Presenting a conformation screen...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-07-11 02:04:39 - In reply to message 2 from ffff
If you set the Accessible parameter to 1, the form input is outputted even when the ReadOnly flag is 1.

  7. Re: Presenting a conformation screen...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-07-11 02:09:54 - In reply to message 3 from Form Class
You can use the SetInputProperty to dynamically set the Accessible attribute of an input. The Accessible attribute overrides the ReadOnly flag for individual attributes.

  8. Re: Presenting a conformation screen...   Reply   Report abuse  
Picture of ffff ffff - 2007-07-11 02:57:06 - In reply to message 7 from Manuel Lemos
But the Accessible parameter would render the text-field as a normal input. The whole point of the confirmation screen is rendering the outputs as text while conserving the values using an invisible field with the same name.

  9. Re: Presenting a conformation screen...   Reply   Report abuse  
Picture of Form Class Form Class - 2007-07-11 03:20:41 - In reply to message 8 from ffff
Further, setting ReadOnly/Accessible values for all the individual inputs is not possible generically from the descendant forms because inputs vary for each form unless we also maintain a list of inputs added for each form or accessing the $form->inputs array which is not recommended. In my case I hacked the confirmation screen spitting out a string of hidden inputs from $_POST and verifying them with $form->inputs to make sure they are not submit/button types, but could be more elegantly done at the ancestor-level from the $form->inputs variable. Setting of the ReadOnly attribute for individual inputs (or whatever needs to be done to also render inputs as hidden) should ideally happen during $form.SetReadOnly( $readOnly, $inputsAsHidden = 0 ) so that they could also be rendered as hidden inputs. Naturally, the only time we want to render all inputs as hidden is when the form is in ReadOnly mode.

Regards,

  10. Re: Presenting a conformation screen...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-07-11 03:30:34 - In reply to message 8 from ffff
Right, setting Accessible to 1 will make an specific input appear as accessible even when the form ReadOnly is set to 1.

If you want to pass any input as invisible, you can use AddInpuHiddenPart instead of AddInputPart.

If you want to display any input as read-only and pass its value as an hidden input, you can use AddInpuReadOnlyPart instead of AddInputPart.

 
  1 - 10   11 - 12