I had a quick look at the code, my comments:
1- try to entirely drop using sessions, they are complicating the code, and creating needless dependencies. Also, it's forcing you to abuse some OOP concepts.
2- HTTP supports methods other than GET & POST (e.g. PUT).
3- Consider passing "options" to the class instead of having methods with long parameter list ( e.g. createForm() )
4- Try to "autoload" class instead of including them by hand
5- to change the interface of the form (visual design & layout) I would have to edit the classes, it's very very hard. Consider using a templating engine ( e.g. Smarty). A better way yet, is to create "renderers" so that you can add a class for whatever renderer you want, e.g. xhtml, xul, wml.... etc
6-   file: form.class.php Line 56. This is a security concern, never trust $_SERVER['PHP_SELF'], you should validate it.
7- if($class != NULL), this is not how you test if the value is NULL or not. Consider using is_null(). This might work for you because you are testing value equality, so NULL == "" evaluates to true. but NULL === "" evaluates to false. Three equal signs test if the two operands are identical; value and type are the same. The argument passed will never be equal to NULL unless you pass NULL to it, because it has a default value of an empty string.

8- To better design the Widgets, consider splitting every widget as its own class (and file). Also make the super Widget class abstract, it shouldn't be instantiated.


I will send more comments soon inshalla when I have the chance to check other stuff. Looks good so far, best of luck.

- 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/
-~----------~----~----~----~------~----~------~--~---

Reply via email to