I am trying to implement a generic form handler that is capable of printing the form and checking the user input.
I want this application to be useful in the end, but I also use it to explore OOP in PHP. The working code at the moment is able to add HTML input elements to the page. These fields are all objects that get added to the Form object. When the user submits, the Form object tells all elements to check their input and create error messages if needed. So far so good. One of the intended applications is to store addresses submitted by visitors to our website. We have users from two countries, with two different zip-code systems. I could ofcourse create a double check in the zipcode-object, but this would mean that it would be possible to submit a zipcode from the other country without any objection by the application. I'd like the zipcode object to ask a question to find out what country we're dealing with and then apply the check of the input depending on the answer. Although these questions are specific to my application, I guess my real question is more general. When you have a containerobject that stores different kinds of elements, how do you give the elements the ability to learn about their surroundings so they can alter their behaviour? I know have: $foo = new Form(); $foo->addToForm(new Element('country')); $foo->addToForm(new Element('zipcode')); $foo->processForm(); I hope I made clear what it is I am trying to do. Hopefully I'll receive a few hints to help me on my way. Thanks, Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php