FormUI changes

19 views
Skip to first unread message

Owen Winkler

unread,
Mar 24, 2013, 10:16:09 PM3/24/13
to habar...@googlegroups.com
As some of you may know, I've been working on refactoring FormUI.

As of now, I've completely rewritten the classes, and they seem fairly
ready for use.

I've updated a significant amount (but not all) of the documentation
here, down to but not including "Creating Your Own Validators":

http://wiki.habariproject.org/en/User:Ringmaster/FormUI

There are some exciting changes in several areas:

* Controls have been changed to use fallbacks, just like themes. As a
result, creating custom templates for controls should be much more familiar.

* Controls no longer have intrinsic labels. When creating a control, if
you want a label, you must explicitly create a label control to go with
it. This allows the control templates to include *only* what is
necessary to make the control work.

* Control constructors are now all identical. No more guessing what
parameters a control has in its constructor, because they're all the same.

* Fluent methods exist to set control-specific values, like the options
for a select control or the caption for a button. These explicit
methods are more clear, and the fluent interface makes them easy to use.

* It is now possible to register a form by name, and then create a form
using just the name. This is interesting because it allows a form to be
created and referenced separately from where it is used, aka "AJAX".

* Getting and processing of controls now happens separately. If you
assign a value to a control within the form generation, the value is
retained, which was not always the case before.

* All control values' save and load routines are now run through
ControlStorage (a FormStorage class).

* You can create forms with FormUI using HTML. You pass the HTML into a
method, and it just goes. This is new and prone to change, but pretty cool.


I'm gradually making my way through all of the forms, converting them to
the new methods. Every form I've come across so far has been
convertible, most of them have been simplified, and some of them have
done something simply that was ugly to do in the old version.

There are a lot of changes, and many changes yet to make to the existing
forms, but if you have a chance to look at the 388 branch and see what's
there (or maybe help convert the remaining unconverted forms), and make
comment, that could be very helpful.

Obviously, one of the things that this change doesn't address is that
the forms now look completely screwed up in the admin...
...and that's all I have to say about that.

But if you could have a look at what's going on in the code, and offer
any comment, that would be super-useful.

Thanks!
Owen

ringmaster

unread,
Mar 28, 2013, 1:28:35 PM3/28/13
to habar...@googlegroups.com
I just merged it to master.  It's not quite done for three reasons that I know of:

* The menu plugin uses an autocomplete-like field to allow the selection of posts.  This control, FormControlAutocomplete, is as-yet incomplete.  The menu plugin may have other issues related to FormUI, though much of it has been overhauled, and that might be the last item.

* The admin "users" page no longer allows the deletion of users.  This is because the form tags that are generated on the page, which previously did not use FormUI, are not properly placed.  The non-FormUI form on that page needs to be replaced with one that is.  On IRC today I mentioned a plan for a new control, FormControlAggregator, which would be a single checkbox that gets its value by aggregating the values of checkboxes that are elsewhere on the page, specified by a CSS selector.  This control would be useful for replacing our many "None/N/All selected" checkboxes at the bottom of lists.

* Since all of the templates have been simplified, the divs and classes that were previously used for controls are likely not present.  As a result, the admin stylesheet is largely ineffective.

Please enjoy/poke at/contribute to these new changes.

Owen


Reply all
Reply to author
Forward
0 new messages