Edit Organisation-Specific Custom Fields for a Contact
Within the Edit Contact Screen, the Custom Fields Table Widget switches to editable input mode for coordinators. Each custom field is rendered with the appropriate Flutter input widget based on its type: text fields use AppTextField, select fields use a dropdown or radio group, and date fields use a date picker. Field values are validated against their type constraints before the edit form can be submitted. The Contact Management Service applies RLS-aware validation and persistence. Peer mentors may see custom fields in read-only mode but cannot edit them, as editing is restricted to coordinator-level roles by RLS policy. This role-based distinction is enforced at both the UI layer (field rendered as read-only) and at the data layer (Supabase RLS rejection on unauthorised write).
User Story
Acceptance Criteria
- Given a coordinator opens the edit contact screen, when custom fields are loaded, then each field is rendered as an editable input with the correct input type (text input, dropdown, or date picker)
- Given a coordinator enters an invalid value in a custom field (e.g., text in a date field), when they attempt to advance or submit, then field-level validation blocks progression with a descriptive error message
- Given a peer mentor opens the edit contact screen, when custom fields are loaded, then custom fields are rendered as read-only and no edit affordance is presented
- Given a coordinator submits updated custom field values, when the Contact Management Service processes the save, then the updated values are immediately reflected on the contact detail screen
- Given an organisation has select-type custom fields with predefined options, when the coordinator taps the field, then a list of the organisation-defined options is displayed for selection
Business Value
Coordinator-controlled custom field editing ensures that structured, organisation-required data is entered by the role with the broadest context and highest accountability. Allowing peer mentors to edit these fields would risk inconsistent or incorrect values being saved, which could corrupt the structured data that feeds into Bufdir compliance reports and internal quality reviews. Role-restricted editing maintains data integrity at the source.