I didn't have time yet to check the code, but by reading the email, here are the comments:
1- A package that does what you mentioned in a very elegent manner, highly extensible exists; PEAR QuickForm
2- It's a very bad idea to store the submitted data in $_SESSION, it's a long story, but I you shouldn't do it.
3- Have you conisdered applying "filters" which filter data after it is submitted? e.g . I trim almost anything coming from a form, so I would apply a filter trim in a very simple OOP manner. $form->applyFilter( 'elementName', 'trim' ). But ofcourse you would want to register valid filters. And also consider having magic constans which do things like: $form->applyFilter( 'elementName', FORM_ALL_ELEMENTS), and this would apply the filter to all the elements.....
I will be writing more on this once I read the code, but none the less, this is a good idea.
- Ammar
On 10/31/06, Al-Faisal El-Dajani
<[EMAIL PROTECTED]> wrote:
Hello all,
The only thing that i hate more than writing HTML is having to do server side validation of user input. It is extremely tedious, repetitive and boring, yet unbelievably important. So, after writing the db connection class and getting great feedback, i decided to share with you what i did to never deal with validation again.
For the developer, the only thing he/she needs to do is something similar to what is written in demo.php. When the form is submitted it directs to valid.php which validates the form, and continues to the form action if it checks out, or goes back to the form, prefilling it with user entered data and highlighting the errors.
Some of the shortcomings that i know of are:
1) You can't have more than one form per page.
2) You have to name your submit button with the name "submit".
3) You can't create multi-page forms.
4) I certainly didn't cover every HTML case out there, but i think the $extra parameter solves that, albeit not too elegantly.
5) The form action will not receive the form data in a $_POST or a $_GET variable. The values will be in $_SESSION['formValues']. It is in a concatenated string format ( field1:value1;field2:value2:... ) , but will be changed to be an associative array.
6) If you want to display many buttons at the end of the form, they will be displayed under each other, and not side by side.
At the moment, i don't care about those things, because i don't have multi-page forms, more than form per page, or more than one button at the end of form. But if this idea was any good, i would like to expand it and use it for future projects.
The widgets class is of special importance to me, because this would facilitate creating HTML elements, and maybe expand it to contain things such as Skype name with user status(online, away, do not disturb, and the like) next to it or someting like that. This would allow an additional layer, where widgets know how to "draw themselves", and the developer can focus on other matters.
Any comments, ideas, improvements, mistakes, or alternatives?
More importantly, would YOU use this code/idea in any of your projects?
--
Al-Faisal El-Dajani
Tel: +962-7-77 799 781
P.O Box: 140056
11814 Amman, Jordan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Jordan PHP Users Group" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/JoPHP
http://Jolug.org/
-~----------~----~----~----~------~----~------~--~---
