Altinn / Altinn/app-lib-dotnet
Prefill/default values for items in repeating groups/lists
- Dominant language
- C#
- Stars
- 8
- Forks
- 27
- Avg merge
- 1h 21m
- Merged PRs (30d)
- 7
Description
### Description
We would like to be able to prefill/initialize items in repeating groups/lists with default/prefilled values (eg. country code for a list of contact persons). Today's solution is to iterate through the list in DataProcessor, making the experience for the end user less than desirable given the need to trigger a change in order for the prefill value to be set, for each new item in the list.
### Additional Information
Given a `List` one solution could utilize default property value in the data model, like:
```CSharp
public class ContactPerson
{
public string Name { get; set; }
public string PhoneNumber { get; set; }
// Initializes PhonePrefix with a default value of "+47"
public string PhonePrefix { get; set; } = "+47";
}
```
As of today, this will not be written to instance data. Another solution could be to enable "defaultValue" on components.
Contributor guide
Research direction
Start by tracing how DataProcessor creates or initializes new items in repeating groups/lists, then compare that path with model property defaults and component defaultValue handling. Done means agreeing on one supported prefill approach and ensuring values such as a ContactPerson PhonePrefix are written to instance data without a user-triggered change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100