[TW5] Store form element values in a local namespace

69 views
Skip to first unread message

John

unread,
Aug 16, 2015, 9:53:28 AM8/16/15
to TiddlyWiki
When I create forms and store its values in fields, those fields are accessible from anywhere within the Tiddlywiki file. It results in a long list of user defined fields and creates problems if I have to use multiple instances of a form or multiple forms.

I have no idea what 'em call it in Tiddlywiki world, But Is there a way to pack these fields into the local scope of a tiddler as a structure and unpack them in transclusions without making them available all over the World ?


Example Code:

<$checkbox field=smoking_status checked='Yes' unchecked='No'>Smoker</$checkbox>

<pre>Smoker: {{!!smoking_status}}
</pre> 


Jed Carty

unread,
Aug 16, 2015, 11:16:19 AM8/16/15
to TiddlyWiki
Any field is available globally. I think the solution to your problem is to use the tiddler widget to set the currentTiddler variable.

Putting {{!!smoking_status}} in a tiddler will always reference the smoking_status field of the containing tiddler. So I think it is what you are describing. If you want to reference other tiddlers than you can transclude the form in another tiddler, or use the tiddler widget like this:

<$tiddler tiddler=TiddlerToModify>
<$transclude tiddler=FormTiddler/>
</$tiddler>

Then if form tiddler has the code you have in your example it will affect the field smoking_status field of TiddlerToModify, not the form tiddler. You can also do this in lists.

I have some stuff about how lists work with this written up here, now that I have moved I will hopefully get around to expanding the learning tiddlywiki section of the site.
Reply all
Reply to author
Forward
0 new messages