1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-02 16:16:18 +00:00
TiddlyWiki5/editions/tw5.com/tiddlers/widgets/RadioWidget.tid
Tobias Beer d6d3aab36a Allow radio widget to work with indexes in a data tiddler (#2104)
* allow radio widget to set an index in a data tiddler

* updated RadioWidget docs, with same demo macro as for CheckboxWidget
in #2103
* removed docs in widget code (seems the wrong place)

* added from version to docs

* revert doc maros to master

* using wikitext-example-without-html and .tip macro now

* fix quotes
2016-12-17 11:51:24 +00:00

41 lines
1.8 KiB
Plaintext

caption: radio
created: 20131212195353929
modified: 20161217112444671
tags: Widgets
title: RadioWidget
type: text/vnd.tiddlywiki
! Introduction
The radio widget displays an HTML `<input type="radio">` that reflects whether a given tiddler field has a specified value. Selecting the radio button sets to the tiddler field to the value.
! Content and Attributes
The content of the `<$radio>` widget is displayed within an HTML `<label>` element also containing the radio button. This means that clicking on the content will have the same effect as clicking on the button itself.
|!Attribute |!Description |
|tiddler |Title of the tiddler to manipulate (defaults to the [[current tiddler|Current Tiddler]]) |
|field |The field of the //tiddler// bound to the radio button|
|index|<<.from-version "5.1.14">> The index of the //tiddler// being [[DataTiddler|DataTiddlers]] bound to the radio button<<.tip "takes precedence over //field//">>|
|value |The value for the //field// or //index// of the //tiddler//|
|class |CSS classes to be assigned to the label around the radio button |
!! Field Mode
This example uses the radio widget to change the `modifier` field of this tiddler:
<<wikitext-example-without-html """<$radio field="modifier" value="JoeBloggs"> Joe Bloggs</$radio>
<$radio field="modifier" value="JaneBloggs"> Jane Bloggs</$radio>""">>
!! Index Mode
Using the radio widget in index mode requires the //index// attribute to specify the name of the index of a [[DataTiddler|DataTiddlers]] to which the specified //value// is assigned.
This example sets the `Tree Frog` index in the tiddler AnimalColours:
<$macrocall $name="wikitext-example-without-html" src="""<$tiddler tiddler="AnimalColours">
<$radio index="Tree Frog" value="green"> green</$radio>
<$radio index="Tree Frog" value="brown"> brown</$radio>
</$tiddler>"""/>