Help needed for creating a select box which sets a field name and a field value simultaneously

35 views
Skip to first unread message

Måns

unread,
May 15, 2015, 7:28:11 AM5/15/15
to tiddl...@googlegroups.com
Hi TwWizards

I'm trying to create a select box where I can select a group and title based on tags. Group should become the field name and the "title" should become the field value...

I've been trying different approaches - which led to solutions for other use cases - this last one is still a little to difficult for me.

This* is how far I've got - as you can see I hardcoded the fieldname (wrote it into the macrocall).
What I really want is to be able to set the "master tag for Group headers" in the macro call. (In this case it is a tiddler tagged with "groupitem") - and when I choose a "sub list tiddler title" from that group item (in this case it is "probability" -  then I want the "FieldName" to change so it becomes the group header title.

[*]
\define sfmsa(GroupItem:"groupitem" FieldName:"probability")
<$select tiddler=<<currentTiddler>> field='$FieldName$'>
<$list filter='[tag[$GroupItem$]]'>
<optgroup label={{!!title}}>
<$list filter='[all[current]tagging[]]'>
<option value={{!!title}}><$view field='title'></option>
</$list>
</optgroup>
</$list>
</$select>
\end

Grouped: <<sfmsa>>

The use case is that I want to automatically set the fieldname to which a field value is written (<<currentTiddler>>) - as a result of which group a choosen tiddler (title) belongs to...

I'm not sure that you (or anybody else for that matter ...) - can follow my thoughts just by looking at the macro text. You might understand it better if you checkout my playground - it is the tiddler $:/SelectFieldMacroSemiAdvanced which holds the code.

The attached screenshot shows that I'm able to select a title from another group than the hardcoded one ("probability")... It would be very nice if the fielname would change to reflect the group header...:

 
Cheers Måns Mårtensson
Reply all
Reply to author
Forward
0 new messages