filter
Mode
Using the checkbox widget in filter mode requires the filter
attribute to contain a filter whose output will determine the checked state of the checkbox. In filter mode, checking the checkbox will not automatically make changes to any field of any tiddler. Instead, you can use the actions
attribute (or the checkactions
and uncheckactions
attributes) to specify what should happen when the checkbox is toggled. It is your responsibility to make sure the actions cause changes to the tiddlers or fields that the filter results depend on, so that the checkbox becomes properly checked or unchecked after the actions have triggered and the filter has updated.
If the filter returns an empty result, the checkbox will be unchecked. Otherwise, if the filter result is non-empty, the checkbox will be checked.
However, if either the checked
or unchecked
attributes (or both) are specified, then their values will be looked for in the filter result, instead of considering any non-empty value to mean checked
.
This example creates the same checkbox as in the , selecting between red
and green
in the colors
list field, but using filters and actions to make the change.
\define checkActions() <$action-listops $field="colors" $subfilter="-red green"/>
\define uncheckActions() <$action-listops $field="colors" $subfilter="red -green"/>
<$checkbox filter="[list[!!colors]]" checked="green" unchecked="red" default="red" checkactions=<<checkActions>> uncheckactions=<<uncheckActions>> > Is "green" in colors?</$checkbox>
''colors:'' {{!!colors}}
That renders as:
colors: