An Empty Optional Field Should Be an Intentional Test Case
Define how an optional field should look when absent. Use three small cases to check headings, fallbacks and a transition from filled to empty content.

The record saves successfully, but its page shows “Subtitle:” followed by nothing. The field was optional in the editor; its surrounding label was not optional in the template. Treat absence as a presentation decision before it becomes an accidental output.
Define what absence means for this field
In this fictional venue directory, an entry has an optional access note. A filled note might explain that the side entrance avoids steps. An absent note means the publisher has supplied no additional information; it does not mean the venue has no access restrictions or that every entrance is suitable.
Agree that meaning with the content owner. Then distinguish an allowed omission from an incomplete required entry. If visitors need the information to make a consequential choice, making the field optional may be the wrong content decision. A template cannot resolve that requirement merely by hiding an empty section.
Write the display rule before inspecting examples
A useful contract could say: “Show the access-note heading and content only when an approved note exists. When absent, omit that section without leaving its separator or blank container. Do not replace absence with a claim about accessibility.” This is a proposed rule for the fictional directory, not an implementation specification for every site.
Choose any fallback deliberately. A neutral “Ask the venue for access information” might be appropriate if the service owner agrees the route and maintains it. An invented reassuring sentence would add information that the empty field never established.
Prepare three small cases
Case one: an ordinary approved note
Create a recognisable entry containing a short, factual note supplied for the test. Record the intended heading, text and surrounding spacing. Inspect the actual rendered section after saving through the supported editing process. This establishes the filled reference case; it does not establish that the directory’s real access information is accurate.
Case two: the note is intentionally absent
Use a second entry with the optional value absent. Confirm the saved state rather than assuming an empty-looking input proves it. Check whether the heading, separator and container follow the agreed omission rule. Record expected and observed treatment separately. “No note; no orphan heading expected” is a more useful check than “empty data should work.”
Case three: a previously filled note is removed
In an authorised test copy, clear an existing note and inspect the saved and rendered state again. This exercises an editing transition that a never-filled entry does not. Look for a surviving label or old displayed value, but do not assume the cause if either appears. Record the specific record, view and conditions for investigation.
Check the actual field behaviour
Field settings can influence what your test record contains. For example, ACF’s Text documentation describes a required setting that prevents empty values and a default value used when creating a new post. A default or validation rule may therefore matter when preparing an intentionally absent example. Check the installed field type and configuration instead of assuming all providers behave alike.
Also agree which values count as meaningful. An empty string, missing stored value, zero and false are not interchangeable content concepts. In a different field, zero might be a legitimate count. Do not use a universal “hide anything false-looking” rule as a substitute for the field’s type, documented return behaviour and intended meaning.
Keep the case with the requirement
Record the field purpose, allowed absence, visible treatment, test-entry identifiers and outstanding question. When the template changes, revisit the filled case and the absence cases together. A correction that removes the orphan heading should still preserve a legitimate filled note.
The finish is an explicit content and display agreement supported by inspected examples. It is neither a guarantee that every empty field is handled nor an instruction to fill every gap with plausible text. Where the absence exposes a missing requirement, settle that requirement before declaring the template ready.
Keep an intentionally empty example beside the ordinary filled example. Sample-data tooling should help you prepare the cases your template needs, including cases you may create manually.
For related preparation, see A Dynamic Template Needs a Small Test-Content Matrix and Teach Dynamic Templates with One Field and One Visible Change.




Discussion 0
What did this article make you think about?