This function will show or hide the required marker on one or more fields on the current page when a given condition is met.
This function is typically used alongside .hideFieldWhen and .showFieldWhen when showing or hiding multiple fields.
It only changes the field labelling, it doesn't change whether the field itself is required or not. You can use .validateRequiredWhen to set the requiredness of a field.
Note that in most site styles, required markers (such as asterisks) are not shown - optional fields are marked as optional and unmarked fields are required.
Also see .showFieldOptionalWhen.
Arguments
| Argument | Type | Description |
|---|---|---|
| fieldNames | Array, required | The names of the fields show or hide the required marker for |
| condition | Expression, required | The expression should return true or false, and will determine whether the markers are shown (true) or hidden (false) |
Returns
None.
Example
In this example, all of the named fields will have their "required" marker shown when the value of the current field (a radio button group) is "show". If false, the "optional" marker will be displayed.

function(helper, fieldName, value, valid, eventName) {
let fields = ['FIELD20', 'FIELD22', 'FIELD30', 'FIELD23'];
helper.showFieldRequiredWhen(fields, value == 'show');
}
