[Usability] In-line form validation

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The current feature release of phpBB 3 is 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Post Reply
User avatar
ameeck
Registered User
Posts: 86
Joined: Sun Nov 13, 2005 6:43 pm
Location: Prague, Czech Republic
Contact:

[Usability] In-line form validation

Post by ameeck »

Currently phpBB does not use any kind of JavaScript on-page pre-validation. I would suggest implementing a framework (probably using jQuery) which could possibly allow this feature.

I would go further and totally recreate the way forms are generated in phpBB.

A very good solution is having a form defined through an object interface in the PHP files, from which hooking up validation (both JS and PHP) could be deployed.

An example from one other project:

You can just assign $form to a template variable and output it in the templates. Another method in the processing script handles the data passed.

Code: Select all

$form = new Form();
$form->addText('name', 'Your name:')
    ->addRule(Form::FILLED, 'Enter your name');

$form->addText('age', 'Your age:', 5)
    ->addRule(Form::FILLED, 'Enter your age')
    ->addRule(Form::NUMERIC, 'Age must be numeric')
    ->addRule(Form::RANGE, 'Age must be in range from %d to %d', array(10, 100));

$form->addCheckbox('send', 'Shipping address:')
    ->addCondition(Form::EQUAL, TRUE);

$form->addText('email', 'Email:', 35)
    ->setEmptyValue('@')
    ->addCondition(Form::FILLED) // conditional rule: if is email filled, ...
        ->addRule(Form::EMAIL, 'E-mail is not valid'); // ... then check email 
Please think before you post.

code reader
Registered User
Posts: 653
Joined: Wed Sep 21, 2005 3:01 pm

Re: [Usability] In-line form validation

Post by code reader »

just to make sure i understand:
it seems that you are discussing two separate things which are not necessarily related.
it is also possible, of course, that i completely misunderstood your post, so i request clarification:

what i understood from your post, you are suggesting:
-- use of javascript, preferably through a library
-- beefing up the template engine to support objectified html forms

while each of these two things sounds like a fine idea in itself, i think it would help to separate this into two discussions, because it seems that they are not tightly related.
of course, if we do those two things, the template engine may help by automating the generation of the call to the javascript validation, but we could use either one of those without the other.

specifically to your suggestions, i want to make a comment and ask some questions:
-- comment: i think it is important that everything should work with javascript disabled on the user agent. validation is good, but everything should still work if it doesn't happen.
-- questions: how does programmatic html form creation work with different styles? does this mean that the template syntax needs to be expanded? if so, would you care to present the additions to the syntax?

peace.

User avatar
ameeck
Registered User
Posts: 86
Joined: Sun Nov 13, 2005 6:43 pm
Location: Prague, Czech Republic
Contact:

Re: [Usability] In-line form validation

Post by ameeck »

My main point is in-line form validation with JS. I just extended the post not to forget my other idea :) I'd put it in a spoiler BBCode if there was one here :)

JavaScript validation is just a bonus feature. There is always a server-side fallback validation.
Please think before you post.

ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: [Usability] In-line form validation

Post by ToonArmy »

I've used Zend_Form quite a bit recently and it makes form generating/validating/processing easy. A similar package will probably be used for form creation in 4.x with the ability to generate JS validation from PHP rules, which really aids usability.
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image

User avatar
ameeck
Registered User
Posts: 86
Joined: Sun Nov 13, 2005 6:43 pm
Location: Prague, Czech Republic
Contact:

Re: [Usability] In-line form validation

Post by ameeck »

ToonArmy wrote:I've used Zend_Form quite a bit recently and it makes form generating/validating/processing easy. A similar package will probably be used for form creation in 4.x with the ability to generate JS validation from PHP rules, which really aids usability.
That's great to here. Yeah, Zend_Form is similar. Such an interface really eases up creating forms. It would be also helpful for modding, as it's only a matter of injecting one object holding the whole form.
Please think before you post.

Post Reply