NewTiddlerWithFormMacro

From knowledgebase
Jump to navigation Jump to search

The newTiddlerWithForm Macro

To create tiddlers that are referencing FormTemplates you may use the {{{<<newTiddlerWithForm...>>}}} macro.

The {{{<<newTiddlerWithForm...>>}}} macro displays a button. When pressed the button creates the requested tiddler and displays it.

If no title is given in the macro (or a tiddler with the given name already exists) the user can enter the tiddlers name in a dialog.

Syntax:

> {{{<<}}}newTiddlerWithForm formTemplateName buttonLabel [titleExpression [askUser]] {{{>>}}}
formTemplateName The name of the tiddler that defines the form the new tiddler should use.
buttonLabel The label of the button
titleExpression A (quoted) JavaScript String expression that defines the title (/name) of the new tiddler.
askUser Typically the user is not asked for the title when a title is specified (and not yet used). When askUser is given the user will be asked in any case. This may be used when the calculated title is just a suggestion that must be confirmed by the user
> ~~Syntax formatting: Keywords in bold, optional parts in [...]. 'or' means that exactly one of the two alternatives must exist.~~

Examples

  • Ask the user for a bug report name and create a bugreport.

{{{ <<newTiddlerWithForm BugReportTemplate "New Bugreport">> }}} <<newTiddlerWithForm BugReportTemplate "New Bugreport">>

  • Create a blog entry tiddler. Let the user confirm the automatically generated title (that contains the current date) or change it.

{{{ <<newTiddlerWithForm

BlogTemplate 
"New Blog" 
'"Blog: "+(new Date()).formatString("YYYY-MM-DD")' askUser

>> }}} <<newTiddlerWithForm <missing '>>'>

BlogTemplate 
"New Blog" 
'"Blog: "+(new Date()).formatString("YYYY-MM-DD")' askUser

>>

Using the build-in newTiddler macro

Instead of the {{{<<newTiddlerWithForm>>}}} macro you may also use the build-in {{{<<newTiddler>>}}} macro to create tiddlers referencing FormTemplates. E.g. you may use the {{{<<newTiddler>>}}} macro to create a tiddler with tags .

In the "text" you need to call the formTiddler macro and in the tagparameters you specify your tags. E.g.: {{{ <<newTiddler

       label:"Button Label"
       text:{{"<<formTiddler MyTemplateTiddler>"+">"}}
       tag:"MyTag1"
       tag:"Three Word Tag" 

>> }}} For details on newTiddler see http://tiddlywiki.org/wiki/NewTiddler_%28macro%29