BlogIntegrations · October 31, 2026 · 5 min read

Contact Form 7 Boolean Mapping: Preserve True, False and Missing Answers

Map CF7 choices to typed CRM booleans. Check actual source shapes, reject unexpected tokens, and preserve missing-value behavior during updates.

A CRM property expects a boolean, but a Contact Form 7 answer arrives as text, a selected-value array or no property at all. Converting that input with a generic truthiness check can silently change its meaning. In JavaScript, the nonempty string "false" is truthy, and an empty array is truthy too.

A form branches into three trays holding a checked disc, an open ring and a blank card.
Generated conceptual illustration; not a product screenshot or measured result.

The reliable solution is an explicit mapping contract for each business question. This guide focuses on a custom adapter after collection. It does not change CF7’s native field validation, implement a newsletter integration or establish a legal consent policy. Inspect your own connector’s actual output before deciding which representations it should accept.

Start with the question’s meaning

“Please call me” and “I accept these terms” are different questions, even if both use a checkbox. The first may represent an optional contact preference. The second may control whether the form can proceed. A required acceptance condition should not be reused as evidence of an unrelated marketing choice.

Write a mapping note with the source field, allowed incoming representations, destination type, missing-value behavior and update behavior. For a new inquiry, an unchecked optional preference might mean false under your chosen contract. For an existing CRM contact, an absent field might instead mean leave the stored preference unchanged.

That distinction belongs to the adapter and destination API. Our missing and intentionally cleared values guide covers update semantics. Decide them before adding a convenience conversion.

Observe the actual submitted shape

The HTML checkbox reference explains that an unchecked standard checkbox is omitted from normal form submission. A checked checkbox without an explicit value uses on. Those are browser rules, not a promise that every CF7 extension or server-side adapter exposes that exact shape.

CF7 checkbox groups use configured choice values, and custom mapping code may expose an array of selected answers. Acceptance fields have their own behavior, described in the official acceptance documentation. Inspect checked, unchecked and rejected fixtures at the precise boundary your code consumes.

Record structure and synthetic values, not real personal answers. If a checkbox represents several services, preserve it as a collection. Do not flatten that question into a boolean just because one selection happens to be present today.

Avoid generic truthiness conversion

The JavaScript Boolean reference distinguishes a boolean value from conversion of another type. A nonempty string does not become false because its characters spell “false.” Likewise, comparing a selected array directly to a scalar does not define a dependable mapping.

The following illustrative function accepts only two explicitly documented string tokens from a hypothetical adapter. It preserves absence as a separate result and rejects unexpected data. It is not a drop-in CF7 hook and deliberately does not accept on, arrays, numeric values or arbitrary labels.

function parsePreference(record, key) {
  if (!Object.hasOwn(record, key)) {
    return { kind: 'missing' };
  }
  const value = record[key];
  if (value === 'true') return { kind: 'value', value: true };
  if (value === 'false') return { kind: 'value', value: false };
  throw new TypeError('Unexpected preference representation');
}

Adapt the allowed representations to an observed, versioned contract. If your source is a one-choice array, validate its cardinality and exact member before converting it. Do not add case folding, trimming or more accepted tokens simply to make an unexplained fixture pass. An explicit compatibility decision is easier to maintain than accidental coercion.

Serialize the destination type deliberately

JSON distinguishes the boolean false from the string "false". Confirm the receiving API’s field type and inspect the serialized request before sending it. A CRM interface displaying an unchecked box is useful evidence, but it does not explain whether the API coerced an invalid string or stored the intended type.

Keep source representation and destination representation separate in your mapping documentation. For example, the adapter might convert a known selected token into a real boolean, then omit the destination property when its result is missing. Another destination may require an explicit operation to clear a value. Follow that API rather than inventing a universal null convention.

Avoid coupling this conversion to submission success reporting. A successfully sent CF7 notification can coexist with a failed destination validation. Keep those stages distinguishable in logs and reports without copying submitted messages into analytics events.

Test changes to existing records

Use a synthetic destination contact whose starting preference is known. Test true to false, false to true, missing input and an unexpected token. Also test a new record so create defaults are not confused with update behavior. Check the destination after processing completes, rather than relying only on an HTTP acceptance response.

Include localization in the review. A visible label changing from English to another language should not silently change the integration’s internal token. If your connector maps displayed text, document that fragility and coordinate label changes with the mapping owner.

For each fixture, retain the expected destination value and a minimal pass/fail observation. Do not use real subscription changes as a convenient production test. Staging fixtures should remain isolated from live contact lists, autoresponders and sales tasks.

Maintain the boundary alongside reporting

Record the accepted input shapes, destination API version, missing-field rule and last review date. Recheck after changing a checkbox, acceptance setting or connector. Keep failures visible so an unexpected token cannot quietly become a positive preference.

Our free Svetlik Analytics for Contact Form 7 plugin can support submission statistics. It does not establish the meaning of a CRM boolean or certify consent. Pair reporting with the form acceptance checklist and a separate verification of the custom adapter’s typed output.