[ TW5 ] add incremental field name?

55 views
Skip to first unread message

Chris

unread,
Aug 15, 2019, 8:31:26 PM8/15/19
to TiddlyWiki
So when adding new tiddlers if there is already a tiddler called "New Tiddler" the new one is "New Tiddler 1". 

Is there anyway to do that but with field names? via the button widget? and possibly tie in inputs that the new field can be populated? ( ex. "field-1": "", "field-2": "", etc )

I found this in old discussion ( [tw] Possible to create a button to add incremental field? ) from 5 yrs ago in which Jed Carty offered this code

<$button>New Field
<$action-setfield $field={{!!count}} $value=<
<whatevervalueyouwant>>/>
<$action-increment $field='count' $increment=1 $prefix='field-'/>
</$button>

I found that when I took out $value and left blank instead of populating the count field with "field-#" it will create a new field called 'field-1' . . . well it was doing it last night not anymore. 
<$button>New Field
<$action-setfield $field={{!!count}} $value="" />
<$action-increment $field='count' $increment=1 $prefix='field-'/>
</$button>

Working on project which I want to list participants ( ex. family members living in a residence during a given date like a Census record ) which could vary from one to like ten or more. I would like to not add a bunch of fields that may or may not be used, but have the ability to add as needed. 

Mark S.

unread,
Aug 15, 2019, 9:15:54 PM8/15/19
to TiddlyWiki
You might explain your requirements a little bit more.

It sounds like you want something like familymember-1, familymember-2...etc

The thing is, that's probably going to be harder to work into reports and solutions down the road. Why not have a list field, family-members, pointing to other people like:

[[Ted Jones]] [[Doug Jones]] [[April Smith]] ...

Good luck!

TonyM

unread,
Aug 15, 2019, 11:07:26 PM8/15/19
to TiddlyWiki
I agree with mark because you can also reorder them and more.

However its quite easy to process field names using [is[current]fields[]prefix[field-]] and variable=fieldname to retain the current tiddler value. You then access the value with <$view field=<<fieldname>>/>

regards
Tony

Reply all
Reply to author
Forward
0 new messages