PHP Classes

How to Fetch the form fields

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  >  Locating addresses on...  >  All threads  >  How to Fetch the form fields  >  (Un) Subscribe thread alerts  
Subject:How to Fetch the form fields
Summary:Is there any way to do this without accessing the Inputs array?
Messages:7
Author:Matías montes
Date:2006-08-24 20:57:15
Update:2006-09-29 13:58:45
 

  1. How to Fetch the form fields   Reply   Report abuse  
Picture of Matías montes Matías montes - 2006-08-24 20:57:15
Is there a better way to list all the fields that have been added to the form other than accessing the inputs attribute?


  2. Re: How to Fetch the form fields   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-08-25 00:37:31 - In reply to message 1 from Matías montes
If you add your fields to the form, why do you need the class to tell the fields that you added?

  3. Re: How to Fetch the form fields   Reply   Report abuse  
Picture of Matías montes Matías montes - 2006-08-31 17:12:41 - In reply to message 2 from Manuel Lemos
I have my form generation wrapped in a component layer and, due to changes in the way my system works, I need to access the form elements from a different layer if certain conditions are met.

Basically, each of my models is able to create a form that will manage its contents, but, previous to the form visualization I now need to do some parsing of the already formed form and modify some fields attributes if they are set, and only under certain special conditions.....

this extra processing I didn't foresee when I designed the system...

  4. Re: How to Fetch the form fields   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-08-31 19:34:26 - In reply to message 3 from Matías montes
OK, I can add a simple function to retrieve an array with all the inputs defined in the form with AddInput, or do you mean the inputs added to the form output with AddInputPart?

Another detail is that if you use custom inputs, these may add implicit inputs to the form. Do you want these additional inputs to appear in the array of inputs returned by that eventual new function?

  5. Re: How to Fetch the form fields   Reply   Report abuse  
Picture of Matías montes Matías montes - 2006-09-01 12:58:02 - In reply to message 4 from Manuel Lemos
I think that only the inputs added using addInput should be enough, at least for what I'm trying to achieve.
Any implicit input should be "private" to the cutom input class implementation, so they shouldn't be accessed by this method.

I was think that if you add inputs like this:

$form->AddInput(array("TYPE"=>"text","ID"=>"input1"));
$form->AddInput(array("TYPE"=>"custom","ID"=>"input2"));
$form->AddInput(array("TYPE"=>"hidden","ID"=>"input3"));
$form->AddInput(array("TYPE"=>"select","ID"=>"input4"));

(many other parameters missing) when I call

$myInputs = $form->MyGetInputsMethod();

I should get an array like:
"input1", "input2", "input3", "input4"

but, if you think it's better to get more information than that, perhaps it could be an associative array with all the data that was set for the input during the form creation.


what do you think?

  6. Re: How to Fetch the form fields   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-09-26 18:33:43 - In reply to message 5 from Matías montes
Ok, I just uploaded a new version that has a function named GetInputs which does what you need.

  7. Re: How to Fetch the form fields   Reply   Report abuse  
Picture of Matías montes Matías montes - 2006-09-29 13:58:45 - In reply to message 6 from Manuel Lemos
Thanks Manuel for keeping up the good work and taking into consideration everybody's opinions