Loading...
 
Skip to main content

History: Tracker Field Rules

Source of version: 13 (current)

Copy to clipboard
            ! Tracker Field Rules
New in ((Tiki21|Tiki 21.0)) - this provides an easy way to make fields in a tracker form show or hide (or be required or not) depending on the settings of other fields in the form.

!! Some brief instructions:
* Go to the Features Control Panel and enable "Enable Vue.js" and "Tracker Field Rules" in the Interface tab
* Go to the field admin page for a tracker
+ {img type="fileId" fileId="1684"}
* Click on a field (try a checkbox for instance)
* Go to the "Rules" accordion section
* Pick true or false for the "is checked" condition
* Choose a field from the actions menu, and then an action (e.g. show)
* Choose a field from the else menu, and then an action (e.g. hide)
+ {img type="fileId" fileId="1683"}
+ {img type="fileId" fileId="1682"}
* Save the field
* Then go to edit an item in that tracker and check and uncheck the checkbox
+ {button href="tiki-tracker-insert_item?trackerId=23&modal=1" _text="create a new item to try this out" _class="click-modal"}

!! Notes on Field Types
* __Category Fields__
** These have the options -+is empty+-, -+contains+- and -+doesn't contain+- like other "collection" fields, but for categories you need to enter the category Id's, not the names.
* __ShowTikiOrg and Ratings Fields__
** Currently (v 21.1) not working as they aren't really normal input fields - possibly will be fixed in future versions.

{icon name="warning"} Note, this is an extremely new feature and should be considered rather fragile as of 21.0 (early 2020). Future changes in the code may mean you need to remake your rules after an upgrade.

!! Using Field Rules in a Wiki Page (with Plugin Tracker)
In ((PluginTracker)) there are two new parameters, -+rules+- and -+rulesparent+-, -+rules+- is a y/n switch so set that to -+y+-, but -+rulesparent+- is a little trickier on a customised tracker plugin form (leave it empty if you are not using a ((Pretty Tracker)) form in your page.

Assuming you are, you need to tell the rules which element is the ''parent'' container element for the field you are acting on (say, to show or hide it).

* First do "inspect element" (this is in Firefox but more browsers do this)
+ {img type="fileId" fileId="1762"}
* Move the rightmost panels out of the way so you can see the document structure
+ {img type="fileId" fileId="1763"}
* Hover over the element you've just inspected and it will light up in the page (here in purple and blue)
+ {img type="fileId" fileId="1764"}
* Then move up the document structure until you find the whole row you would want to show or hide
+ {img type="fileId" fileId="1765"}

This form is a simple wiki table, so the container element is the -+tr+- (table row) which contains the input and the label, so your selector will be simply -+tr+-, but to make sure it doesn't get confused if the table's inside another one use -+tr:first+-, so your markup should be:
{CODE(colors="tiki")}{tracker trackerId="42" wiki="tracker test tpl" rules="y" rulesparent="tr:first"}{CODE}



Related:
* ((Trackers))
* ((PluginTracker))
* ((PluginJQ)) (the former way to achieve this behavior in Tiki < version 21.0)


Alias names for this page:
(alias(Tracker Rules)) | (alias(TrackerRules)) | (alias(TrackerFieldRules)) | (alias(Tracker Rule)) | (alias(TrackerRule)) | (alias(TrackerFieldRule)) | (alias(Rule)) | (alias(Rules))