On Friday, January 10, 2020 at 1:07:08 AM UTC+3:30, TonyM wrote:
>
> 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".
>
Thanks Tony!
>
> 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.
>
This is a nice design pattern! I think this can also provides a textbox for
online data gathering like an online questionnaire. Or one can give some
numerical values to answers and then calculate the average and like that!
> 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/f6d23f00-3f34-4ca8-9e57-937a4d906346%40googlegroups.com.