PHP Classes

Form arrays

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  >  Upcoming Visual HTML ...  >  All threads  >  Form arrays  >  (Un) Subscribe thread alerts  
Subject:Form arrays
Summary:Is it possible to use form arrays with the Forms class?
Messages:5
Author:Chris Gibson
Date:2006-04-10 20:13:21
Update:2006-04-21 12:53:13
 

  1. Form arrays   Reply   Report abuse  
Picture of Chris Gibson Chris Gibson - 2006-04-10 20:13:21
I have recently started using the Forms Generation and Validation class with great success, even integrating Smarty templates very easily. Thanks!

However, I have been thinking of using form arrays in my scripts -- eg,

<input type="text" name="array[element]" />

Is it possible to configure the class to permit these? I've been running some of my own tests but it does not appear that fields such as these are being processed correctly.

Thanks again,

Chris

  2. Re: Form arrays   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-04-10 20:51:13 - In reply to message 1 from Chris Gibson
I am not sure how do you want it to work.

If you use brackets in names, PHP converts the values in arrays, but the class will not get the values from arrays, as that would require additional complication parsing the name.

On the other hand, the class itself uses angle brackets to pick values for multiple select fields.

So, for now I advise that you use a different name notation, like array_index instead of array[index] .

  3. Re: Form arrays   Reply   Report abuse  
Picture of Matías montes Matías montes - 2006-04-20 21:57:06 - In reply to message 2 from Manuel Lemos
Hi, after some evaluation I decided to use the form validation class in a site I am developing. But I came into a problem which I consider, the best solution is to use an array of text inputs. Is there any way to acomplish this using this class?

I have a variable number of text fields, each of them has the quantity of a certain product. I also have that same number of hidden fields, each with the Id for that product. Thay are in the same order so I can then iterate them both in order to link a product id with an ammount

Any idea or alternative solution would be apreciated

  4. Re: Form arrays   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2006-04-20 22:33:05 - In reply to message 3 from Matías montes
In your case I think it would be worth investing on the development of a plug-in to implement a custom input that encapsulates the behavior for your product row.

The class documentation has plenty of information on how to build custom input plug-in classes.

There are also several examples of real world plug-in classes that imp&#314;ement custom inputs composed of several inputs like you want: date input, capctha, linked select, etc.. It seems that what you want is simpler than these.

Later if you are filling capable, you can extend your custom input class or create a new one that implements your concept of array of inputs.

Alternatively, you can user the layout_vertical custom input, which is just a wrapper around an array of inputs that are laid out vertically.

Just let me know if you need further guidance.

  5. Re: Form arrays   Reply   Report abuse  
Picture of Matías montes Matías montes - 2006-04-21 12:53:13 - In reply to message 4 from Manuel Lemos
Thanks I'll give some thought to your idea and if I come up with the custom input favorably i'll publish my solution in the site