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.

I am working on a code pattern for generic way to allow edit current 
tiddler elements. I have more complex solutions but would like to make it 
easy to use.

Regards
Tony





On Wednesday, January 8, 2020 at 7:56:01 AM UTC+11, Mohammad wrote:
>
> The below code uses a button to create more input boxes to get 
> field-name/field-value pairs from user.
> It then will be used to create a tiddler with many fields as user like!
>
> This works, but it seems a bit complicated! 
>
> What do you propose?
>
>
> \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>>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/6bac844d-8bc1-4c51-b85a-07e2165fd4bb%40googlegroups.com.

Reply via email to