Drop Down Fields/Content Filtering

92 views
Skip to first unread message

Darth Mole

unread,
Jun 17, 2021, 2:56:53 AM6/17/21
to TiddlyWiki
Possibly a strange question.

I have a massive list of <option>organization type</option> as well as others lists. 

I found, and got, the following drop down field working with a Tiddler for the field itself, and then another tiddler with all the options, one a new line, and surrounded by the option code. I then transclude the tiddler with the list into the selection section of the field code:


However, by default it seems that no matter what, when a selection is made, it immediately writes to a new, or the current tiddler, and replaces everything with the chosen value.

Below is a snippet from a code provided to me in an earlier thread in order to generate a new Tiddler based on the values typed into the text fields.

\define temp() $:/temp/input/$(currentTiddler)$

\define tocscript()
<h1>$(storyname)$</h1>
<div class="tc-table-of-contents">
<<toc-selective-expandable "$(storyabbrev)$" "sort[title]">>
</div>
\end

|      Story Name*:|<$edit-text tiddler=<<temp>> field="storyname"/>    |
|   Story Abbreviation**:|<$edit-text tiddler=<<temp>> field="storyabbrev"/>  |

<$tiddler tiddler=<<temp>>>
<$button> Create Story
   <$vars storyabbrev={{!!storyabbrev}} storyname={{!!storyname}}>
   <$action-setfield $tiddler={{!!storyabbrev}} text=<<tocscript>> tags="Stories" />
   <$action-deletetiddler tiddler=<<temp>> />
   </$vars>
</$button>
</$tiddler>

My question is if there is a way to show a drop down field, with the options prepopulated, and have it act like the edit-text fields above vs overwriting the entire tiddler immediately with the selection?

Or is there another way to reference/pick from predefined content in the body of the tiddler while editing it? 

Thanks!

Eric Shulman

unread,
Jun 17, 2021, 3:38:32 AM6/17/21
to TiddlyWiki
On Wednesday, June 16, 2021 at 11:56:53 PM UTC-7 iamdar...@gmail.com wrote:
My question is if there is a way to show a drop down field, with the options prepopulated, and have it act like the edit-text fields above vs overwriting the entire tiddler immediately with the selection?

When you define your $select widget, you need to specify the tiddler=... and field=... parameters, just as you do with the $edit-text widget.
Otherwise, the $select widget defaults to changing the "text" field of the current tiddler.

Thus:
<$select tiddler=<<temp>> field="organization">{{OrgList}}</$select>
Where the "OrgList" tiddler's text field has content like this:
<option>Foo</option>
<option>Bar</option>
<option>Baz</option>
<option>Mumble Frotz</option>
<option>Gronk</option>

Alternatively, you can simplify the OrgList tiddler's contents by using a $select widget containing a <$list> widget, like this:
<$select tiddler=<<temp>> field="organization">
   <$list filter={{OrgList}} variable="org"><option><<org>></option></$list>
</$select>
Where OrgList contains just a white-space separated list of values, like this:
Foo Bar Baz [[Mumble Frotz]] Gronk
(note the use of doubled square brackets surrounding values that contain spaces)

As a third alternative, you could store the "OrgList" in a field of the current tiddler.  Thus:
<$select tiddler=<<temp>> field="organization">
   <$list filter={{!!orglist}} variable="org"><option><<org>></option></$list>
</$select>
where the "orglist" field value contains a white-space separated, bracketed list as shown above.

enjoy,
-e

Darth Mole

unread,
Jun 17, 2021, 8:46:35 PM6/17/21
to TiddlyWiki
Thank you so much! Thank you, thank you, thank you!
Reply all
Reply to author
Forward
0 new messages