How to have a field's key pre-populated when creating new tiddlers?

In my tiddlers, I usually add a field source-url whose value I set to the URL of the content’s source. Currently, I have to add this field manually.

How do I make the “New Tiddler” action to open a new tiddler with the source-url field already added?

Similarly, the _canonical_uri should be visible when creating a new image tiddler.

Both tm-new-tiddler and action-createtiddler allow you to provide additional fields to the new tiddler in the form fieldname="fieldvalue"so you can just use source-url="" or _canonical_uri="".

  • You need to use tm-new-tiddler in the action-sendmessage widget not in a buttons parameters.
1 Like

The $:/core/ui/Buttons/new-tiddler uses the $:/core/ui/Actions/new-tiddler to create a new tiddler.

$:/core/ui/Actions/new-tiddler looks like this:

\define get-tags() $(textFieldTags)$ $(tagsFieldTags)$
\whitespace trim
<$vars textFieldTags={{$:/config/NewTiddler/Tags}} tagsFieldTags={{$:/config/NewTiddler/Tags!!tags}}>
<$action-sendmessage $message="tm-new-tiddler" tags=<<get-tags>>/>

Change the line with the <$action-sendmessage to

<$action-sendmessage $message="tm-new-tiddler" tags=<<get-tags>> source-url="https://"/>

The same thing also works with the new-image button. The action is: $:/core/ui/Actions/new-image

Also see: Docs for the action-sendmessage

As a second option it would be possible to use the ActionCreateTiddlerWidget in combination with the send-message and the WidgetMessage: tm-edit-tiddler to open the newly created tiddler.

ActionCreateTiddler has an advangage, if you want to use a template-tiddler instead of hardcoding the actions.

1 Like