[TYPO3-dev] Advanced Forms
Edwin de Jong
g.e.dejong at student.utwente.nl
Tue Jan 24 23:46:40 CET 2006
Hello developers of Typo3,
Does anyone knows if there is an extention that is 'like' mailForm but
actually is able to group the form fields into mulitple sections and even
pages? Have conditions and such? If not, I will write such an extention.
Therefor, I really appreciate any ideas, suggestions for implementation, etc.
Basic functionality proposals:
1. per field validation based on conditions (each field can have multiple
conditions, like regular expressions or simple arithmetic comparisons)
2. fields being grouped into sections
3. sections being grouped into pages
4. hints (question mark with popup on the right)
5. conditional field display and section display (for example, when a user
marks a checkbox a javascript will display or hide a certain other section
based on changing the style)
6. Progress indication (for example, when an extended form is placed over
three pages, a big 1, 2 and 3 display above which change color from grey to
red to show where you are)
7. ability to change between 'in-line' form display and 'block' form display
(basically, sometimes you want a layout that has the form inputs layout
horizontally eg. when entering a birthday or a postal code and a city name)
8. Different and extendible types of entry fields
Some of the rendering of the above mentioned points can be done with
templates.
I'd rather design this from the ground up. I'm experienced in making these
kind of applications. As a developer for a local company I've designed such a
system being fed with information from an XML messaging server. Here part of
the validation happened on the XML server, part happened on the webserver
(Cocoon) and part in the users browser. *Very* complex system, for the rest
of this mail I use a lean version of this.
While designing I just ran into the same problems we were having before... for
example: each field, section and form has two predicates, one which - if true
- will display the item, and one which - if true - will validate the item.
Each predicate is associated with other predicates by inheritance, there are
predicates like quantors, logical operators, arithmetic comparitors, regular
expressions etc. etc. Some of these predicates have operants which are not
predicates but parameters (eg. the value that was entered by the user, an SQL
query that returns one value or even the results from typoscript). The
problem however is that: a user should be able to navigate through the
different pages of the form and there is a small chance that these predicates
are bypassed when using the back button of the browser. Basically: when you
make the visibility of a page [n] (or subelement thereof) dependent on a
value on page [m], where [n]<[m], then you can still reach page n by using
the back button. Basically, the predicates need to be 'ordered'.
For this I think what I need is a small functional language with list
comprehension to do the predicate checking, might be overkill though. Eg. to
do:
FOREACH f: this (f.type = 'date' => f.value > date_born_field && f.value <
NOW())
if you want to check if the dates entered by a user are actually after he was
born. Since these languages are all easily parsable, and can be built up in a
hierarchical way, its quite easy to make a user-interface to change these
expressions like the one above.
Ok, I've also made a simple entity relationship diagram. Basically, what I
want to put in the database is:
Form (relates to 1 Predicate/NULL)
FormInstance (relates each to a Form and zero or more FieldInstances)
FieldInstance (contains a value in XML format (to allow Date's and such)
Page (relates to one Form, relates in 'next' to Page/NULL and relates in
'previous' to Page/NULL, relates to 1 Predicate/NULL in 'visible' and relates
to 1 Predicate/NULL in 'Validation')
Section (relates to one Page, relates in 'next' to Section/NULL and relates in
'previous' to Page/NULL, relates to 1 Predicate/NULL in 'visible' and relates
to 1 Predicate/NULL in 'Validation')
Field (relates to Section, relates in 'next' to Field/NULL and relates in
'previous' to Field/NULL, relates to 1 Predicate/NULL in 'visible' and
relates to 1 Predicate/NULL in 'Validation)
Type (relates to 1 Predicate/NULL in Validation)
Well, at first I also wanted to model the predicates in the database, but now
I feel more in making either a seperate language ala Lisp, or use XML to
describe them.
Basically it contains the following entities (I only describe one, the rest is
obvious):
BinaryLogicalPredicate (like, the 'AND' operator), contains a predicate A and
B and resolves to true if A and B are both true. In the same sense: OR and
FOLLOWS.
UnaryLogicalPredicate (like, the 'NOT' operator)
QuantorPredicate (like the 'FORALL' operator which has three arguments: one
unique identifier, one reference to a Form, Page or Section and one
Predicate. Is true when the Predicate is true for each 'identifier'
substituted by the reference to each Field contained in beforementioned Form,
Page or Section).
UnaryScalarPredicate (eg. 'IsSet' scalar predicate which has one argument
reference to a field F and returns true when F is set by the user)
BinaryScalarPredicate (eg. '>' operator which has two arguments A and B which
are of the same (sortable) type and returns true when A > B). Also in this
league: a regular expression matcher.
I guess we need also a set of operators on the Scalars, but maybe we can use
the help of PHP for this (eval... better not).
Well, this is my first quick specification draft. I would really appreciate
the input of others on this subject.
Regards,
Edwin de Jnog
More information about the TYPO3-dev
mailing list