Feature Proposal: MacroToListInstalledFormFieldTypes


In building the wizard/UI to simplify data form app creation, I need a list of field types, and other meta info about those types.

Similarly, make the DataForms field type table in the system doc dynamically generated rather than hard-coded.

Description and Documentation

Add something like QUERY{"{Forms}" format='$key' separator=','} that returns a formated list

Behind the scenes, this QUERY is accessing information stored in the $Foswiki::cfg{Form} hash.

The $Foswiki::cfg{Form} hash is populated a configure checker, which accesses the defaults for those values from either a Config.spec or (preferably) from the Foswiki::Form::Field class definition itself to simplify maintainence, and so that only classes that compile get added to the cfg hash.

formating work needed

The QUERY macro will need some additional cleverness to support format-ing complex structures. It looks from the code, that I can create a Foswiki::Serialise::Format that uses the foswiki-core formating system (header, footer, pager, and more) to do this, and then need to add $key/name and $field() accessors into the hash.


QUERY{"{Forms}" format='$key' separator=','} would return text,textarea,datetime,radiobutton,select,....

QUERY{"{Forms}{datetime}"} would return a perl hash

QUERY{"{Forms}{datetime}{class}"} would return 'Foswiki::Form::Datetime'

QUERY{"{Forms}{datetime}{description}"} would return 'yeah, dates :)'

QUERY{"{Forms}{checkbox}{modifiers}"} would return ['buttons', 'values'] (remember, by default we render in Perl-ish)

Data stored

  1. type name
  2. Perl Class name
  3. short description
  4. default
  5. multi-value / single
  6. modifiers (good luck figuring how to express constraints, and then how to use them)
  7. custom attributes
  8. size type / format / some indicator
  9. no, this will never be a complete list, as its impossible to encode all possibilities in a data defintion




-- Contributors: SvenDowideit, PaulHarvey - 20 Jun 2012


Sven refactored some discussion into the proposal above

along the way, the irc discussion noted that we should add dataforms to lots of shipped topics: plugin, skin, contrib, VarMACRO, jqplugin, the non-existant VarPREFERENCES, and who knows what else. **MAKE SOME MORE PROPOSALS**

-- SvenDowideit - 21 Jun 2012

I would expect QUERY{"{Forms}"} to do something like return the list of data forms defined in the current web. Would you mind a bit more verbosity:


-- KipLubliner - 28 Jun 2012

yes and no :).

QUERY{"{Forms}"} is $Foswiki::cfg{Forms} and by that nature can't be a list of things defined in a web / topics.

However, you have a good point, it might make more sense for this to be $Foswiki::cfg{Form}{FieldTypes} or something.

-- SvenDowideit - 02 Jul 2012

It's not clear to me how this gets populated. Is Foswiki::Form dynamically scanned when populating $Foswiki::cfg? Is it bound to a function to allow it to be scanned only on demand? Or pre-scan and populate in configure? How are you going to avoid doing a one-off hack to support this?

-- CrawfordCurrie - 02 Jul 2012

I've slightly changed the wording to try to make it more obvious:

_Behind the scenes, this QUERY is accessing information stored in the $Foswiki::cfg{Form} hash.

The $Foswiki::cfg{Form} hash is populated a configure checker_

no hack, just a system similar to plugins.

-- SvenDowideit - 02 Jul 2012

the FormTypes checker populates the array of hashes (because QUERY can't do proper hash access when there are keys like 'select+values')

the first commit adds QUERY{"{FormTypes}[].type"} - to get a comma separated list of field types (with one entry per modifier)

on http://trunk.foswiki.org/Development/MacroToListInstalledFormFieldTypes :
  • radio,text,checkbox,checkbox+values,color,select,select+multi,select+values,select+multi+values,date,label,listfielddefinition,rating,fielddefinition,textarea,textboxlist

or if you want details from one type QUERY{"{FormTypes}[type='select+multi']" style="Perl"}
  • [{'size' => 1,'type' => 'select+multi','class' => 'Foswiki::Form::Select','multivalued' => 1}]

frustratingly, adding a value to AccessibleCFG needs help.

-- SvenDowideit - 22 Oct 2012

Marked this merged-to-core as-is. The basic function of listing the types is functional on trunk. Task was WaitingForRelease.

-- GeorgeClark - 09 Feb 2015
Topic revision: r24 - 05 Jul 2015, GeorgeClark - This page was cached on 15 Feb 2017 - 06:28.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License