Skip to content

Improve nested field identification for collection fields using Blazor's FieldIdentifier system #91

@phmatray

Description

@phmatray

Summary

EditContext's flat model design means nested field identifiers (e.g., Items[0].ProductName) are currently handled at the component level rather than through Blazor's built-in FieldIdentifier system. The current approach works but could be improved for better integration with Blazor's validation infrastructure.

Context

Introduced in #20 (one-to-many collection field support). The CollectionFieldComponent manages its own validation state per item rather than leveraging EditContext.NotifyFieldChanged with proper nested field identifiers. This means:

  • Validation messages are rendered by the component itself, not by Blazor's ValidationMessage<T>
  • EditContext.IsModified() doesn't reflect changes in collection item fields
  • Third-party validation summary components won't pick up nested field errors

Suggested Approach

  • Implement a custom FieldIdentifier strategy that encodes collection index and property path (e.g., Items[0].ProductName)
  • Propagate field change notifications to the parent EditContext
  • Enable ValidationMessage and ValidationSummary to display nested errors natively

Acceptance Criteria

  • Collection item field changes notify the parent EditContext
  • EditContext.IsModified("Items[0].ProductName") returns correct state
  • Blazor's ValidationSummary displays nested field errors
  • No regression in existing collection field functionality

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions