How can I more easily create topics that use DataForms - do I really need to write HTML code each time?

This topic is designed to be a generic 'helper', reusable for any DataForm you may have, which makes a UI to create and summarise topics using a given DataForm.

ALERT! Foswiki:Extensions.FlexFormPlugin is not enabled. You need this plugin installed and enabled for this helper topic to work.

It provides the following:
  • An inline HTML form which can create a new topic using a DataForm that you specify.
    • Warns if the user doesn't have permission to create the topic
  • A summary table of the topics that use the specified DataForm
  • A summary/count in the footer of cell values for formfields that are checkbox/select/radio/textboxlist type.

Example

%INCLUDE{
  "%TOPIC%"  section="creator"
  inweb="%SYSTEMWEB%"  topic="FAQAUTOINC0"
  form="%SYSTEMWEB%.FAQForm"
  action="save"
}%

---++++ Summary
%INCLUDE{
  "%TOPIC%"  section="summarytable"
  inweb="%SYSTEMWEB%"  form="%SYSTEMWEB%.FAQForm"
}%

Test:
%RENDERFOREDIT{form="System.FAQForm"}% Create

Summary

%SEARCH{ "form.name='System.FAQForm'" type="query" web="System" nototal="on" header="| Topic | %RENDERFORDISPLAY{ form="System.FAQForm" format="*$name*" separator=" | " }% | Modified | By |" format="| $topic | %RENDERFORDISPLAY{ form="System.FAQForm" format="$formfield($name)" separator=" | " }% | $isodate | $wikiname |" footer="||%RENDERFORDISPLAY{ form="System.FAQForm" format="$percntIF{ \"'$type'=~'^(select|checkbox|radio|textboxlist)'\" then=\" $dollarpercntCALC{$COUNTITEMS($ABOVE())}$dollarpercnt \" }$percnt" separator="|" }%||| Total: $ntopics" }%

Sections

  • creator - show formfields to create a new topic using a particular form. Variables (see CommandAndCGIScripts for more info):
    • inweb - web to create topics into
    • topic - topic name pattern, eg. FooAUTOINC0
    • form - form to create with
    • redirectto - redirect somewhere after the entry is created, Eg. MyProject.Congratulations
    • action - the action to perform on submit: edit (continue editing the record after submit) or save (just save)
    • editpart - when used with action = edit, editpart may be set to form in which case the user is presented with the form part of the topic to edit.
    • templatetopic - a topic which is used as a template for the newly created topic. Its content & metadata will be copied into the new topic & the edit formfield values will be pre-populated from it.
    • topicparent - the parent for the newly created topic
  • summarytable - show a summary of the topics using the form, with summary of cell values in the footer for checkbox/select/radio/textboxlist formfields

%STARTSECTION{"creator"}%%IF{
  "NOT context authenticated OR '%topic%' allows 'CHANGE'"
  then="$percntINCLUDE{\"%TOPIC%\" section=\"showcreator\"}$percnt"
  else="$percntINCLUDE{\"%TOPIC%\" section=\"showperms\"}$percnt"
}%%ENDSECTION{"creator"}%

%STARTSECTION{"showperms"}%<blockquote class='foswikiHelp'>%I% To create an entry, you need to be
logged as a member of one of the following:
%EXPAND{"$percntALLOWWEBCHANGE$percnt" context="%inweb%.%topic%"}%
</blockquote>%ENDSECTION{"showperms"}%

%STARTSECTION{"showcreator"}%<form method="POST" action="%SCRIPTURLPATH{"%action%"}%/%inweb%/%topic%">
%RENDERFOREDIT{form="%form%"}%
%BUTTON{"%MAKETEXT{"Create"}%" icon="newtopic" type="submit"}%
%CLEAR%
<input type="hidden" name="onlywikiname" value="off" />
<input type="hidden" name="onlynewtopic" value="on" />
<input type="hidden" name="formtemplate" value="%form%"/>
%IF{"defined templatetopic AND templatetopic"
  then="<input type='hidden' name='templatetopic' value='%templatetopic%'/>$n"
}%%IF{"defined redirectto AND redirectto"
  then="<input type='hidden' name='redirectto' value='%redirectto%'/>$n"
  else="<input type='hidden' name='redirectto' value='%BASEWEB%.%BASETOPIC%'/>$n"
}%%IF{"defined editpart AND editpart"
  then="<input type='hidden' name='action' value='%editpart%'/>$n"
  else="<input type='hidden' name='action' value='form'/>$n"
}%%IF{"defined topicparent AND topicparent"
  then="<input type='hidden' name='topicparent' value='%topicparent%'/>$n"
  else="<input type='hidden' name='topicparent' value='%BASETOPIC%'/>$n"
}%
</form>%ENDSECTION{"showcreator"}%

%STARTSECTION{"summarytable"}%%SEARCH{
  "form.name='%form%'"
  type="query"
  web="%inweb%"
  nototal="on"
  header="| *Topic* | %RENDERFORDISPLAY{
    form="%form%"
    format="*$name*"
    separator=" | "
  }% | *Modified* | *By* |"
  format="| [[$web.$topic][$topic]] | %RENDERFORDISPLAY{
    form="%form%"
    format="$formfield($name)"
    separator=" | "
  }% | $isodate | [[$wikiusername][$wikiname]] |"
  footer="||%RENDERFORDISPLAY{
    form="%form%"
    format="$percntIF{
      \"'$type'=~'^(select|checkbox|radio|textboxlist)'\"
      then=\" $dollarpercntCALC{$COUNTITEMS($ABOVE())}$dollarpercnt \"
    }$percnt"
    separator="|"
  }%|||
*Total:* $ntopics"
}%%ENDSECTION{"summarytable"}%


A test example exists at https://wiki.trin.org.au/Sandbox/TestTopic56

Comments

FlexFormPlugin is used extensively in WikiWorkbenchContrib. Similar functions as the both above are RenderSimpleTopicCreator and RenderTopicsOfType.

-- MichaelDaum - 21 Sep 2011

Support.FAQForm edit

TopicClassification FrequentlyAskedQuestion
Subject Data forms, Extension, User interface
Topic Summary Describes a helper topic that uses FlexFormPlugin to make a reusable UI for creating and summarising DataForms topics
Extension FlexFormPlugin
Interested Parties
Related Topics Faq41
Topic revision: r4 - 27 Dec 2011, ArthurClemens - This page was cached on 04 Jun 2017 - 07:06.

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