-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form data: Remove hidden values when submitting #1709
Comments
Relevant discussion with examples of |
Relevant discussion about deleting uploaded files when the uploader itself has been hidden: We could perhaps do that before we go to |
Relevant input, RemoveHiddenData also deletes data you don't want to remove. One example is a hidden id on a repeating group which doesn't provide any user value and hence is hidden, but should definitely be stored. |
Yup, I believe that's covered by the first point: Reset the data back to what we originally got when loading the data model from the backend. Meaning, we only reset the changes the user made. The example here was a Dropdown that is always hidden, but used to display a text value in the repeating group table, and if that's always hidden (but maybe the backend sets data on the repeating group) there is no user changes for us to reset. However, if the user actually deletes the whole row, we have no choice to just tell the backend the user deleted the row (by removing it from the form data). If the app developer does not want it to be possible to delete entire rows, they must disable the delete button (which is already an option for repeating groups). |
Removing |
Some additional information that we see in V4: |
@jhhssb Yes, that's a known issue with the current implementation (in the backend), and something we're planning to 'fix' with this suggestion to implement a solution (in the frontend instead). It's possible to work around the issue in apps, for example by duplicating data (when displayed in a purposely hidden component) or hiding the component using ruleHandler based ("older-style") dynamics (which the backend doesn't know about). |
Jeg trudde den gamle dynamikken ikke var støttet i v4 @olemartinorg ? |
Den er fortsatt støtta - og vi har ingen konkrete planer om å fjerne støtten enda (men heller ikke særlig med forbedringer, utenom at helper-objektene i RuleHandler.js nå er valgfri i v4). |
Relevant (eksempel på noe som kan automatisk testes): |
Description
The backend already has
RemoveHiddenDataPreview
, but this feature should be moved toapp-frontend-react
instead, and enhanced with a few improvements.When the last known component bound to a path in the data model is hidden, we should:
ProcessDataWrite
, as they will either be re-applied or they'll possibly leave unwanted side-effects.RemoveHiddenDataPreview
with hidden repeating group sets row values tonull
instead of deleting rows app-lib-dotnet#321).To demonstrate the point of this functionality, let's say pretend we have this form:
And the data model looks something like this:
In this example, the repeating group in the UI is using the
hiddenRow
functionality to only show rows ofSF_type = pet
(SF
in this context means shadow field). Let's pretend this persons children are fetched from official and reliable sources, but the pets are added manually (and are not verified). Verification and other shadow fields are added byProcessDataWrite
.As soon as the user changes their selection to "No" for having pets, app-fronted-react should remove the two pets from the data model, and revert the data model to the original state (i.e. removing the shadow fields along with the pets if they were added by
ProcessDataWrite
, or, if the rows were already present in the data model when we loaded it, just removethe values the user typed in, along with the ones we got from the backend). And if the user changes their selection back to "Yes", the pets should re-appear as if nothing happened.
The purpose of this feature is to make it possible to use hiding of components to make the form more dynamic, without having to worry about the data model getting out of sync with the UI. It is useful for validation, as validation code can make some more assumptions about the data model being in a somewhat valid state (i.e. not having pets when the user says they don't have pets), and it also becomes a privacy feature as the user can hide data they don't want to share with the receiver of the form.
Additional Information
RemoveHiddenDataPreview
with hidden repeating group sets row values tonull
instead of deleting rows app-lib-dotnet#321The text was updated successfully, but these errors were encountered: