\define myTid() xx$:/temp/sample\define myfilter() [range[1,$(flt)$]]\define id_fldName() fldn$(cnt)$\define id_fldValue() fldv$(cnt)$
\define create-recoreds()<$wikify name=flt text={{{ [<myTid>get[counter]]~[[1]] }}}><$list filter=<<myfilter>> variable=cnt>
<<getInputs>></$list></$wikify>\end
\define getInputs()<$edit-text tiddler=<<myTid>> index=<<id_fldName>> tag=input default="" placeholder="field name"/><$edit-text tiddler=<<myTid>> index=<<id_fldValue>> tag=input default="" placeholder="field value"/>\end
<$button>add<$action-setfield $tiddler=<<myTid>> counter={{{[<myTid>get[counter]add[1]]~[[2]]}}}/></$button><$button>reset<$action-setfield $tiddler=<<myTid>> counter="1"/><$action-setfield $tiddler=<<myTid>> text=""/></$button>
Number of records: <$count filter="[<myTid>indexes[]]" /><br>Counter: <$transclude tiddler=<<myTid>> field="counter"/><br>
<<create-recoreds>>
\define createMyTiddler()<$vars newTitle={{{ [<newtiddlerdName>get[text]] }}}><$wikify name=flt text={{{ [<datafieldsTid>indexes[]count[]] }}}> <$list filter=<<myfilter>> variable="cnt"><$action-setfield $tiddler=<<newTitle>> $field={{{ [<datafieldsTid>getindex<id_fldName>] }}} $value={{{ [<datafieldsTid>getindex<id_fldValue>] }}} /></$list></$wikify></$vars>
\end
\define datafieldsTid() $:/temp/sample\define newtiddlerdName() $:/temp/tidName\define myfilter() [range[1,$(flt)$]]\define id_fldName() fldn$(cnt)$\define id_fldValue() fldv$(cnt)$
\define create-records()<$wikify name=flt text={{{ [<datafieldsTid>get[counter]]~[[1]] }}}><$list filter=<<myfilter>> variable=cnt>
<<getInputs>></$list></$wikify>\end
\define getInputs()<$edit-text tiddler=<<datafieldsTid>> index=<<id_fldName>> tag=input default="" placeholder="field name"/><$edit-text tiddler=<<datafieldsTid>> index=<<id_fldValue>> tag=input default="" placeholder="field value"/>\end
<!-- Interface -->
<$button>add<$action-setfield $tiddler=<<datafieldsTid>> counter={{{[<datafieldsTid>get[counter]add[1]]~[[2]]}}}/></$button><$button>reset<$action-setfield $tiddler=<<datafieldsTid>> counter="1"/><$action-setfield $tiddler=<<datafieldsTid>> text=""/><$action-setfield $tiddler=<<newtiddlerdName>> text=""/></$button>
Number of records: <$count filter="[<datafieldsTid>indexes[]]" /><br>Counter: <$transclude tiddler=<<datafieldsTid>> field="counter"/><br>
<<create-records>>
<$edit-text tiddler=<<newtiddlerdName>> field=text tag=input default="" placeholder="new title"/>
<$button actions="">Create Tiddler<<createMyTiddler>></$button>
Hi Mohammadthis is another excellent example of how to use TW.Would it be possible to add tags and a tiddler type selection to the form?
I added an example in the post below, that you may be interested in.
On Thursday, January 9, 2020 at 11:03:51 PM UTC+3:30, J Mc wrote:Hi Mohammadthis is another excellent example of how to use TW.Would it be possible to add tags and a tiddler type selection to the form?Please have a look at https://groups.google.com/d/msg/tiddlywiki/h9WI6UCPuJM/QbYywce3CAAJThe above code is used in Commander!
Mohammad
<$list filter="[[$:/data/industry-experience-fields]indexes[]]" variable=fieldname>
<$checkbox field=<<fieldname>> checked="yes" unchecked="no" default="no"> <$text text={{{ [[$:/data/industry-expierence-fields]getindex<fieldname>] }}}/></$checkbox><br>
</$list>Mohammad,I am quite interested in the coding methods you are using. I thought this was an appropriate place to share other methods of adding fields to tiddlers, part of "creating a tiddler".
The "just in time field addition" is where your view template allows you to edit, thus create fields when and if required, rather than creating them before hand. The edit or checkbox etc... does the field creation for you. Of course you need to do this via a template so you can "edit the current Tiddler".I have a commercial project where I am doing this, the customer asked for additional checkboxes on a person record. Since I expect they will want more in the future I used a Dictionary tiddler to store field names and description, then need only add another to have it appear in their person tiddlers.<$list filter="[[$:/data/industry-experience-fields]indexes[]]" variable=fieldname>
<$checkbox field=<<fieldname>> checked="yes" unchecked="no" default="no"> <$text text={{{ [[$:/data/industry-expierence-fields]getindex<fieldname>] }}}/></$checkbox><br>
</$list>So in this case the field will only exist if given a value, so my report logic will test if yes OR "no"/blank.