Skip to content

Commit 2f0251c

Browse files
committed
docs: add documentation for contact field label modifier
Add documentation for the new < /dev/null | label modifier that displays human-readable labels for select and boolean contact fields instead of stored values. Related to mautic/mautic#12620
1 parent 7968d74 commit 2f0251c

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

docs/channels/emails.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,28 @@ To use custom date fields in tokens, use the following format:
141141
142142
The date outputs in a human-readable format, configured in the settings in your Global Configuration > System Settings under 'Default format for date only' and 'Default time only format'.
143143

144+
Label modifier for select and boolean fields
145+
---------------------------------------------
146+
147+
For select and boolean field types, you can display the human-readable label instead of the stored value by using the ``|label`` modifier:
148+
149+
.. code-block:: php
150+
151+
{contactfield=select_alias|label}
152+
{contactfield=bool_alias|label}
153+
154+
This is useful when your select fields store technical values but you want to display user-friendly labels in your Emails. For example:
155+
156+
- A country select field storing ``us`` can display ``United States``
157+
- A boolean field storing ``1`` can display ``Yes``
158+
159+
The modifier also works with company fields:
160+
161+
.. code-block:: php
162+
163+
{contactfield=company_select_alias|label}
164+
{contactfield=company_bool_alias|label}
165+
144166
Contact replies
145167
===============
146168

docs/configuration/variables.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,40 @@ Variables
88

99
``Hi {contactfield=firstname|there},``
1010

11+
Token modifiers
12+
***************
13+
14+
Label modifier for select and boolean fields
15+
=============================================
16+
17+
For select and boolean type fields, you can use the ``|label`` modifier to display the human-readable label instead of the stored value. This is particularly useful when your select fields store values like codes or IDs but you want to display friendly labels to your Contacts.
18+
19+
**Syntax:**
20+
21+
.. code-block:: text
22+
23+
{contactfield=field_alias|label}
24+
25+
**Examples:**
26+
27+
For a select field with alias ``country_select`` that has options like ``us`` (United States), ``uk`` (United Kingdom):
28+
29+
- ``{contactfield=country_select}`` - displays the value: ``us``
30+
- ``{contactfield=country_select|label}`` - displays the label: ``United States``
31+
32+
For a boolean field with alias ``is_subscriber``:
33+
34+
- ``{contactfield=is_subscriber}`` - displays the value: ``1`` or ``0``
35+
- ``{contactfield=is_subscriber|label}`` - displays the label: ``Yes`` or ``No``
36+
37+
This modifier works for both Contact fields and Company fields:
38+
39+
- ``{contactfield=company_type|label}`` - displays the label of a company select field
40+
- ``{contactfield=company_active|label}`` - displays the label of a company boolean field
41+
42+
.. note::
43+
The ``|label`` modifier only works with select and boolean field types. For other field types, it will display the regular value.
44+
1145
Contact fields
1246
**************
1347

0 commit comments

Comments
 (0)