Toggle menu

helper.showFieldOptionalWhen(fieldNames, condition)

This function will show or hide the optional 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.

Also see .showFieldRequiredWhen.

Arguments

ArgumentTypeDescription
fieldNamesArray, requiredThe names of the fields show or hide the optional marker for
conditionExpression, requiredThe 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 "optional" marker shown when the value of the current field (a radio button group) is "show". If false, the "required" marker will be displayed, which is typically nothing, depending on your site's styling.

showFieldOptionalWhen

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

Last modified on 11 September 2026