RADIO and TAGS: Adding dinamic tags in Current Tiddler (is it possible?)

Hey guys!

As a beginner, I’m having trouble building a tiddler using $radio to “add” and not just “replace” tags in the Current Tiddler. Below is the code that I imagine to be the starting point to perform such a task.

<$radio field="tags" value="1 a M"> a) item-1</$radio><br>
<$radio field="tags" value="1 b M"> b) item-2</$radio><br>
<$radio field="tags" value="1 c M"> c) item-3</$radio><br>

DIFFICULTY:

  1. This code works fine in TiddlyWiki 5.2.7, but it just replaces the “current tags” with the “new tags” in each $radio. How do I add the “new tags” to the Current Tiddler and not simply “replace” the “old tags”?

QUESTIONS:

  1. Is there somewhere in the TiddlyWiki documentation that I can delve deeper into the question (link)? I’ve looked a lot in the documentation, but I couldn’t find anything that helps me.

  2. How would the code be adapted to add “dynamic tags” conditioned to the $radio (is it possible)?

  3. How to replace the literal “1 c M” in the code with a global variable?

<$radio field="tags" value="1 c M">

Why a NewTags variable (or something similar), so that the content of NewTags is dynamic and not static?

  1. Is there a simpler way to do this?

Thanks in advance for everyone’s attention!

Hi @Claudio_Rieper,

Could you please edit your message and surround your code with single backticks (inline code) or triple backticks (code block) ?

Then, about your questions:

Question #1: I think you can do what you want using:

  • The actions parameter to list what must be done upon selection of a radio widget, using:
  • The <$action-listops> widget in order to add/remove individual tags to the list

Documentation: Radio Widget, Action-Listops Widget

Question #2: sorry, I don’t understand what you want. Could you please elaborate ?

Question #3: create a new tiddler, tag it with $:/tags/Macro, and add this to its text field:

\define value3() 1 c M

Then the radio widget code can become <$radio field="tags" value=<<value3>>>...

Question #3bis: parameters can be dynamic using filters inside a filtered transclusion, like this <$radio field="tags" value={{{ [{!!tags}enlist-input[]] -[[b]] -[[c]] [[a]] }}}>

Fred

Hello @tw-FRed!

Thank you very much for the strength.

SECOND QUESTION:

  1. REWRITTEN: Each time the tiddler with the options is shown, I want to add “new tags” (dynamic tags) instead (like in the literal example: “1 c M”).

I believe that in your example with value=<<value3>> this already gives a possible solution for the “dynamic tags” that I need. But it brings up another question.

NEW QUESTIONS:

  1. Can I load “new tags” (dynamic tags) in value3() each time I go through the same tiddler (question)?
  2. Can I load value3() into another tiddler so that it has “new tags”?
  3. How to load new values ​​into value3, each time it passes through the tiddler (what would the code)?
  4. Does value3 by being tagged $:/tags/Macro become a global variable so that I can put “new tags” each time I go through the same tiddler?

You didn’t tell us the purpose of your wiki, but is seems to me it’s a kind of quiz, with several questions and you want to collect the answers. Am I right ?

If so, you might want to have a look at this: TiddlyWiki toolmap - Dynalist

Fred

I can’t follow the original question but wonder if the radio widget is not what you want. Perhaps consider the checkbox widget and its new listField parameter

Hi @Claudio_Rieper,

This code might help you:

\define radio-actions()
<$action-listops $tags=<<actionValue>>/>
\end

\define clear-actions()
<$action-setfield radio=""/>
<$action-listops $tags="-a -b -c"/>
\end

<$radio field="radio" value="a" actions=<<radio-actions>>> a) item-1</$radio><br>
<$radio field="radio" value="b" actions=<<radio-actions>>> b) item-2</$radio><br>
<$radio field="radio" value="c" actions=<<radio-actions>>> c) item-3</$radio><br>

Current `radio` field value: {{!!radio}}

<$button actions=<<clear-actions>>>Clear</$button>

Paste it in a new tiddler, add some tags then play with the radio inputs and the button.

Hope this helps,

Fred

1 Like

Hello @tw-FRed and @TW_Tones !

Thank you so much for your support and feedback.

Yes, I’m really working on a “quiz”. Thanks a lot for sharing the link to the TiddlyWiki toolmap - Dynalist (I didn’t know that, but it wasn’t for lack of research, I just needed the right way).

But the “quiz” I’m making has some unusual features:

a) It needs to accumulate the answer of at least two people (hence the addition of “different tags” for the same question/tiddler).
b) At the end I present a FINAL SUMMARY (only with the answers that were the same for all), which I do with the $list filter command.

DIFFICULTIES:

  1. I’ll take a look at the toolmap - Dynalist, but I don’t know if I’ll be able to change it myself to adapt it to accomplish this task.
  2. For those who just want to solve a problem, it might be interesting. But for a beginner like “me” who wants to solve the question and also learn how to do it in the simplest way, even if it takes more work and is not as efficient, I think your explanation will help me more to learn.

DOUBT in the CODE:

a) The variable <<actionValue>> is a system variable? Or where it is defined. I didn’t see any macro or variable names being defined in the code you suggested (learning a little more).

Therefore, thank you very much for your attention.

Hi @Claudio_Rieper,

Yes, this variable is a system variable, it contains the selected RadioWidget value parameter and it can be used in the code referenced by the actions parameter. You can get more information in the official RadioWidget documentation.

Fred