Skip to content

Commit 76b2365

Browse files
committed
Added {index} and {total_items} variables to options fieldtypes
1 parent efdeff0 commit 76b2365

3 files changed

Lines changed: 60 additions & 13 deletions

File tree

docs/fieldtypes/checkboxes.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ You can use a single variable for Checkboxes to render a comma-separated list of
4949

5050
### Variable Pair
5151

52-
Using a variable pair, allows for customization of the output.
52+
Using a variable pair of field name, allows for customization of the output.
5353

5454
{field_name}
5555
{item}<br>
@@ -63,7 +63,20 @@ Two
6363
Three
6464
```
6565

66-
By default, `{item}` will render the item's label To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable:
66+
The following variables are available inside field's tags pair:
67+
68+
| Variable | Description |
69+
| --------------- | --------------------------------------------------- |
70+
| `{item}` | Label of selected item |
71+
| `{item:label}` | Label of selected item |
72+
| `{item:value}` | Value of selected item |
73+
| `{count}` | Counter for each of selected items, starting with 1 |
74+
| `{index}` | Counter for each of selected items, starting with 0 |
75+
| `{total_items}` | Total number of selected items |
76+
77+
By default, `{item}` will render the item's label.
78+
79+
To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable:
6780

6881
{field_name}
6982
Label: {item}<br> {!-- 1 --}
@@ -90,15 +103,17 @@ TIP: **Tip:** It is recommended that you use the value in conditionals, as it ty
90103

91104
TIP: **Tip:** Checkboxes, Multiselect and Selectable Buttons all default to showing the label. Radio Buttons and Selects default to showing the value.
92105

93-
### Limit Parameter
106+
### Parameters
107+
108+
#### `limit`
94109

95110
This parameter limits the number of selected items output by the tag. It works for both the single variable, as well as the tag pair.
96111

97112
```
98113
{field_name limit="2"} {!-- One,Two --}
99114
```
100115

101-
### Markup Parameter
116+
#### `markup`
102117

103118
As a single tag, a checkbox will display a comma separated list of values. If you want an HTML list, you can use markup="ul" or markup="ol" to change the output to the equivalent html list
104119

@@ -112,7 +127,7 @@ Which will render as
112127
<li>Orange</li>
113128
</ul>
114129

115-
### Backspace Parameter
130+
#### `backspace`
116131

117132
When used as a tag pair, checkboxes are a looping pair. Backspacing removes characters (including spaces and line breaks) from the last iteration of the loop. For example, if you put a `<br>` tag after each item you'll have this
118133

docs/fieldtypes/multiselect.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,21 @@ Two
6363
Three
6464
```
6565

66-
By default, `{item}` will render the item's label. To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable:
66+
67+
The following variables are available inside field's tags pair:
68+
69+
| Variable | Description |
70+
| --------------- | --------------------------------------------------- |
71+
| `{item}` | Label of selected item |
72+
| `{item:label}` | Label of selected item |
73+
| `{item:value}` | Value of selected item |
74+
| `{count}` | Counter for each of selected items, starting with 1 |
75+
| `{index}` | Counter for each of selected items, starting with 0 |
76+
| `{total_items}` | Total number of selected items |
77+
78+
By default, `{item}` will render the item's label.
79+
80+
To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable:
6781

6882
{field_name}
6983
Label: {item}<br> {!-- One --}
@@ -90,15 +104,17 @@ TIP: **Tip:** It is recommended that you use the value in conditionals, as it ty
90104

91105
TIP: **Tip:** Checkboxes, Multiselect and Selectable Buttons all default to showing the label. Radio Buttons and Selects default to showing the value.
92106

93-
### Limit Parameter
107+
### Parameters
108+
109+
#### `limit`
94110

95111
This parameter limits the number of selected items output by the tag. It works for both the single variable, as well as the tag pair.
96112

97113
```
98114
{field_name limit="2"} {!-- One,Two --}
99115
```
100116

101-
### Markup Parameter
117+
#### `markup`
102118

103119
As a single tag, a multi select will display a comma separated list of values. If you want an HTML list, you can use markup="ul" or markup="ol" to change the output to the equivalent html list
104120

@@ -112,7 +128,7 @@ Which will render as
112128
<li>Orange</li>
113129
</ul>
114130

115-
### Backspace Parameter
131+
#### `backspace`
116132

117133
When used as a tag pair, Multiselect are a looping pair. Backspacing removes characters (including spaces and line breaks) from the last iteration of the loop. For example, if you put a `<br>` tag after each item you'll have this
118134

docs/fieldtypes/selectable-buttons.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,21 @@ When allowing multiple items to be selected, Selectable Buttons will usually be
6060
{item}<br>
6161
{/field_name}
6262

63-
By default, `{item}` will render the item's label. To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable:
63+
64+
The following variables are available inside field's tags pair:
65+
66+
| Variable | Description |
67+
| --------------- | --------------------------------------------------- |
68+
| `{item}` | Label of selected item |
69+
| `{item:label}` | Label of selected item |
70+
| `{item:value}` | Value of selected item |
71+
| `{count}` | Counter for each of selected items, starting with 1 |
72+
| `{index}` | Counter for each of selected items, starting with 0 |
73+
| `{total_items}` | Total number of selected items |
74+
75+
By default, `{item}` will render the item's label.
76+
77+
To access the value and label separately, simply add a `:value` or `:label` modifier to the `{item}` variable:
6478

6579
{field_name}
6680
Label: {item}<br>
@@ -98,11 +112,13 @@ TIP: **Tip:** Checkboxes, Multiselect and Selectable Buttons all default to show
98112

99113
NOTE: **NOTE:** For Select fields used in [Custom Member Fields](control-panel/member-manager.md#custom-member-fields) and [Category Group Details Tab](control-panel/categories.md#details-tab), the modifiers are not currently available in conditionals, and _must_ be based on the value, e.g. `{if some_cat_field == 2}`
100114

101-
### Limit Parameter
115+
### Parameters
116+
117+
#### `limit`
102118

103119
This parameter limits the number of selected items output by the tag. It works for both the single variable, as well as the tag pair.
104120

105-
### Markup Parameter
121+
#### `markup`
106122

107123
When allowing for multiple selections, a single tag will display a comma separated list of values. If you want an HTML list, you can use markup="ul" or markup="ol" to change the output to the equivalent html list
108124

@@ -116,7 +132,7 @@ Which will render as
116132
<li>Orange</li>
117133
</ul>
118134

119-
### Backspace Parameter
135+
#### `backspace`
120136

121137
Backspacing removes characters (including spaces and line breaks) from the last iteration of the loop when using a variable pair. For example, if you put a `<br>` tag after each item you'll have this
122138

0 commit comments

Comments
 (0)