Use a Form builder for all phpBB Forms

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Use a Form builder for all phpBB Forms

Post by EXreaction » Sat Feb 16, 2013 1:23 am

In 3.x we currently build all forms manually. This means we must build the PHP code to display the form, validate input, and perform actions, and build all the HTML for the forms (which is basically all redundant code except for the names and field types). With a form builder, the backend would handle displaying, validating, potentially handling some actions, and building all the HTML from some rules and specifications in PHP.

A significant portion of phpBB's code can be removed and cleaned up if we had some form builder that used a simple API and was flexible enough that every element we use in a form (perhaps including the posting form) was available on any page just by specifying a different input type. This is just a guess, but I would expect at least a third of the HTML code used in phpBB is in forms that could be removed (possibly more).

This would make adding or altering forms extremely simple (no editing HTML) and also much more reliable (forms are unit tested and HTML output for forms will not differ in different areas of phpBB). Extensions could also very easily modify any form to add or alter variables without having any issues with board styles.

Symfony has a Forms system which we could probably use as the backend for this:
http://symfony.com/doc/master/book/forms.html

The most obvious drawbacks to this is that it will severely break any existing mods which alter the phpBB forms and that at lot of code will be changed to make the transition from old forms to a form builder for everything, but I do not think the first issue is too much of a concern due to the benefits that would be realized with a form builder and the latter is just a matter of someone doing it (I would be interested in doing it for 3.2) and someone reviewing it (which would not be too bad if broken up into many PRs).

User avatar
Ger
Registered User
Posts: 293
Joined: Mon Jul 26, 2010 1:55 pm
Location: 192.168.1.100
Contact:

Re: Use a Form builder for all phpBB Forms

Post by Ger » Sat Feb 16, 2013 8:49 am

Well, I agree this would be a major plus to the current system, no doubt about it. However: it requires a lot of rewriting of existing code as you stated, making me think something like this would probably better fit in the 4.0 plans rather than in the 3.x plans.
Above message may contain errors in grammar, spelling or wrongly chosen words. This is because I'm not a native speaker. My apologies in advance.

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: Use a Form builder for all phpBB Forms

Post by imkingdavid » Sat Feb 16, 2013 6:03 pm

I could support something like this being in 3.2 or 3.3.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
Pony99CA
Registered User
Posts: 986
Joined: Sun Feb 08, 2009 2:35 am
Location: Hollister, CA
Contact:

Re: Use a Form builder for all phpBB Forms

Post by Pony99CA » Fri Feb 22, 2013 10:16 pm

Would there be an event (or events) for controlling forms (adding or deleting fields, changing the style, etc.)? If so, this sounds like a good idea; otherwise I'd say no.

Also, would forms with CAPTCHAs be supported (the registration page and the posting page if you're a guest) or would those forms have to use the old method? What about forms with Custom Profile Fields?

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Use a Form builder for all phpBB Forms

Post by MichaelC » Sat Feb 23, 2013 2:32 pm

+1. If we were to use symfony forms component we should probably also change over validation for forms to use the symfony validation component also?
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Use a Form builder for all phpBB Forms

Post by EXreaction » Sat Feb 23, 2013 4:59 pm

All forms could easily be modified via events with this.

The symfony validation should be used as well.

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Karlsruhe, Germany
Contact:

Re: Use a Form builder for all phpBB Forms

Post by naderman » Fri Mar 29, 2013 12:33 pm

Generally +1 - This is obviously a huge change and I don't think it needs to happen all at once. We should introduce the form system in 2 or 3 places, and then expand it to everywhere else over time.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: Use a Form builder for all phpBB Forms

Post by MichaelC » Fri Mar 29, 2013 2:23 pm

naderman wrote:Generally +1 - This is obviously a huge change and I don't think it needs to happen all at once. We should introduce the form system in 2 or 3 places, and then expand it to everywhere else over time.
+1
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Use a Form builder for all phpBB Forms

Post by EXreaction » Sun Dec 08, 2013 7:25 pm

I've been working on implementing Symfony Forms into phpBB: https://github.com/phpbb/phpbb/pull/1922

It's really quite fantastic; the only HTML needed to show the form is: {{form(form_name)}}

Some style work needs to be done on it so it fits into the phpBB theme, but it can be completely customised per form as well:
http://symfony.com/doc/2.3/book/forms.html

User avatar
wintstar
Registered User
Posts: 108
Joined: Sun Dec 02, 2012 1:38 pm
Location: Lanngöns/Hessen Germany
Contact:

Re: Use a Form builder for all phpBB Forms

Post by wintstar » Tue Dec 10, 2013 7:00 pm

New install from here

ticket/12066

Fatal error: Class 'Symfony\Bridge\Twig\Form\TwigRendererEngine' not found in C:\xampp\htdocs\12066\phpbb\template\twig\twig.php on line 117

PHP Version 5.4.19
MySQL(i) 5.5.32
Greeting Stephan :-)

Quote: "To achieve the possible, the impossible has to be tried again and again" (Hermann Hesse (1877-1962)).
A look into the future phpBB 3.1.0 - Board, current Builds
A look into the future phpBB 3.1.0 - Board-Plus, Extensions in the test

Post Reply