enhancement
major
minor
defect
critical
major
minor
major
#30133
View layer: a field mandatory by dynamic visibility loses its required marker on a validation change
Problem
In a React view-layer <form>, AttributeFieldControl#applyMode (com.top_logic.layout.view, form/AttributeFieldControl.java) computes the mandatory state of a field from its mode: a dynamic-visibility answering MANDATORY, or the create/edit annotations for DEFAULT, capped by the write right. It sets the required marker of the chrome accordingly (_chrome.setRequired(mandatory)).
The validation listener of the same control then resets the marker to the static mandatory flag of the field model:
public void onValidationChanged(FieldModel source) {
...
_chrome.setRequired(source.isMandatory());
}
FieldModel#isMandatory() reflects the attribute's static mandatory declaration only. A field that is mandatory only through its dynamic visibility (or only on creation) therefore shows its * until its validation changes for the first time - e.g. when a constraint reports an error or an error disappears - and loses it from then on. Conversely a statically mandatory field that the mode makes read-only, disabled or hidden gets the marker back on a validation change.
Reproduction
An attribute without mandatory="true" whose dynamic-visibility answers MANDATORY, plus a constraint on it. Open a create form: the field shows *`. Enter a value the constraint refuses: the error appears and the `* disappears.
Fix
The validation listener keeps the mandatory state that applyMode computed (store it in a field and re-apply it, or call the part of applyMode setting the chrome state) instead of reading the static flag.