Need some help with $set or $reveal widgets

103 views
Skip to first unread message

Spangenhelm

unread,
Sep 27, 2015, 7:42:40 PM9/27/15
to TiddlyWiki
Hi everybody,
i have created a form where i can enter a title (and several other fields at the same time) that allows me to create a new tiddler but i need to be sure that the name of the new tiddler does not already exist otherwise it will be replaced without warning when i will create it so i have tried to use the $set widget with a value and emptyvalue attributes to display a message wether the name is taken or not by another tiddler but i am having troubles to set it, same thing with the $reveal widget.
In this case the value to test (the new name) is located in a field called "draft.title" in a tiddler called "Temp Test" (any name with a space)

Thank you for your help and time, much appreciated ;-)
Ps: i have no obligation on what to use so if you have another idea i'm open to suggestions.

Tobias Beer

unread,
Sep 28, 2015, 1:56:06 AM9/28/15
to tiddl...@googlegroups.com
Hi Spangenhelm,

I think it would greatly speed up this exercise
if you could dump some example markup here.

Best wishes,

– tb

Evolena

unread,
Sep 28, 2015, 3:31:41 AM9/28/15
to TiddlyWiki
For a similar use-case, I've used a simple list widget with a filter testing if the new title is an existing tiddler:

@@.tc-alert-highlight <$list filter="[{Temp Test!!draft.title}is[tiddler]]">Caution, <$link><<currentTiddler>></$link> already exists!</$list>@@

I assume here that the "Temp Test" tiddler is always used for storing the entries of your form (with the new title in the draft.title field of this tiddler). If it i not the case, please provide more precise indications of how you've really don your form.

Spangenhelm

unread,
Sep 28, 2015, 11:17:58 AM9/28/15
to TiddlyWiki
Ok this is what i have used in my case with the advices of Evolena:

<$edit-text tiddler="Temp Tiddler" placeholder="Title" field="draft.title" tag="input" type="text"/>

This is a input where i can enter any title for a new tiddler, then aside of it:

<$set name="myVariable" filter="[{Temp Tiddler!!draft.title}is[tiddler]]" value="exist" emptyValue="">
<$text text=<
<myVariable>>/>
</$set>

which allow me to display a message if the name is already taken (i was having trouble to find the right number of brackets and braces in the filter attribute)

first we need to modify a shadow tiddler before use (because of a refresh issue, discussed here: https://github.com/Jermolene/TiddlyWiki5/issues/1937)

Due to Tobias a PR is pending to correct this for the next tw version (5.1.10)

Thank you both for your help! Btw Tobias no big deal but it's a "L" at the end of "Spangenhelm" not a "i" ;-)

Evolena

unread,
Sep 29, 2015, 3:41:23 AM9/29/15
to tiddl...@googlegroups.com
I don't understand why you absolutely want to use a set or reveal widget, as you only use the variable to display it. Is there a reason I don't see?
My list example works perfectly fine when typing the new title, even if a tiddler with the same title is created in the meanwhile, without having the refreshing issue of the set widget to be corrected.

Spangenhelm

unread,
Sep 29, 2015, 5:48:25 AM9/29/15
to TiddlyWiki
Shame on me you are exactly right! it is just that i was too focused on the filter part my mind just forgot about the rest of the code...my bad!
I will add your solution to my "tw manual" ! Many thanks
Reply all
Reply to author
Forward
0 new messages