fix: [DHIS2-19820] create special section for attributes not assigned to a section #4289
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



DHIS2-19820
These changes targets section forms containing tracked entity attributes. The purpose is to enable program rule assignment of attributes that are part of the program, but not part of the section form. The technical solution here is to devise a special section for all such "rogue" elements, and have it be omitted from rendering (like in DHIS2-19604).
After implementing this, some issues with validation errors came up. The reason turned out to be twofold: First, there is a complete validation of the form itself when the form loads, and the new section did not take part in it. This has been corrected by always making the section hidden rather than excluding it completely from rendering. Second, the rule engine runs once while the form is loading, but at the end of this execution it did not validate the assign effects. Consequently the assigned attributes were treated as invalid until the rule engine was run a second time, by making a change in the form.
While scrutinizing how the form-loading call to the rule engine was implemented (in the profile widget), it turned out it got called more often than it was supposed to. Thus I added a simple stopping mechanism in
useLifecycleas a remedy.