[Twisted-web] Formless, custom form layout
matt at pollenation.net
Sat Jun 18 08:23:08 MDT 2005
Richard Wall wrote:
> Have just learnt on irc that a replacement for formless is imminent...
Grr, I keep telling people this in #twisted.web ... forms is *not* a
replacement for formless. Feel free to use forms if it meets your needs
but it's really only an HTML forms toolkit.
Perhaps I should explain my reasoning for forms better ...
Formless is really a naked object implementation. Formless is about
exposing the interface (attributes and methods) of an application's
object on the web.
In theory, formless is agnostic about how and where the forms are used
although, at present, there is only webform. Christopher Armstrong
(radix) once wrote a GTK+ renderer for formless typed interfaces but I
think it's probably dead now.
forms, by comparison, is not about object interfaces; it's about
explicitly creating a Form, adding fields to it, rendering it, and
processing it (with validation). Because forms is only interested in
HTML, it also allows a field's widget to be switched easily, without
having to create a new Typed subclass. For instance, I can add a Date
field to a forms form and choose to render that as a text input, three
inputs (dd/mm/yyyy) or even a <select> list of predefined dates, just by
changing the widget.
My original goal with forms was to provide a reasonably flexible HTML
forms package that developers *and* formless.webform could use. It will
never replace formless because it's working at a lower level but it
could potentially replace a lot of formless.webform. Unfortunately, I've
never had time to achieve the formless part of that goal but forms is
quite usable as it is.
In some ways, formless is actually more flexible than forms because it
supports almost complete customisation of the HTML output (see Nevow's
customform example). Personally, I find it quite cumbersome to use and,
since writing forms, I have not needed to customise the form to that
extent anyway. I have to admit that there are times when better control
of the generated HTML would be nice, but I've always got away with it so
While I'm on the subject ;-) ... my pet hate is seeing people "abuse"
formless: using a nested TypedInterface to group attributes so they are
on the same form and submitted in one request; using autocallable to
submit a bunch of attributes because storing the data is easier in a
method than trying to hook into formless after the attributes are set.
I also dislike having to subclass Typed to provide a different widget,
even though the value I get back does not change.
Anyway, please try forms out and let me and the other Nevow developers
know what you think of it. If there is enough interest, and I can find
time, I will happily move it into Nevow. Heck, I'll even write some
tests for it ;-). If we can get formless.webform to use it, without
breaking everything people are already doing, then even better.
> Richard Wall wrote:
>>Phil Mayers wrote:
>>>Richard Wall wrote:
>>>>I am trying to customise my Formless layout based on
>>>>examples/customform.py, but I'm not sure how I can group inputs in
>>>Good question. I asked the same one a while back (no reply - maybe the
>>>mail didn't get through). I mused:
>>It did, but I didn't spot it until after I'd posted my message. I've
>>learned alot since.
>>>I suspect I can subclass annotate.Typed or use the complexType stuff to
>>>somehow group a textbox and dropdown together into one logical bit of
>>>HTML that is rendered as a single "control"
>>>...but other commitments have kept me from revisiting this
>>For custom output look at custom renderers. You have to register them as
>>adaptors using compy.registerAdaptor.
>>Read this article if adaptors are new to you (they were to me)...
>>Incase your wondering where Nevow registers it's default adaptors (I
>>did) they're in nevow/__init__.py.
>>A multiple choice element (missing from Nevow)...
>>...I'd like to see this (or something similar) included as default. It's
>>a very common form pattern.
>>A date parser element. User can enter date into text box however they
>>A fix for the output of radio lists...
>>>I get a 404
>>I think they expire after a while. Have used another pastebin here.
>>>>That's my ideal layout, can anyone give me hints on howto achieve it?
>>>Let me know if you find out!
>>I found out on #twisted.web from fog, STemplar and others.
>>First checkout examples/customform.py from Nevow svn but it doesn't
>>demonstrate argument slots (as opposed to argument patterns)
>>Here's an example of argument slots and patterns...
>>So you do get control over each arguments layout and position. The
>>default Nevow argument pattern doesn't validate (div inside span!).
>>Using dl,dt,dd makes more sense.
>>You might also want to apply this patch to nevow...
>>Hope this saves you some time.
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
/ \__ Matt Goodall, Pollenation Internet Ltd
\__/ \ w: http://www.pollenation.net
__/ \__/ e: matt at pollenation.net
/ \__/ \ t: +44 (0)113 2252500
/ \ Any views expressed are my own and do not necessarily
\__/ reflect the views of my employer.
More information about the Twisted-web