AutoEditForm/AutoCreateForm one field can determine values in another field

Using Blazor and AutoQuery.

On AutoEditForm or AutoCreateForm instances, how can the value in one field control the options in another field.

For example, lets say i have an opportunity, which has stage and type fields. Based on the type of opportunity, I want to filter stage values that can be selected. What is the best way to go about this?

public enum OpportunityStage
{
    Prospecting,
    Pledged,
    ClosedWon,
    ClosedLost,
    Withdrawn,
    Posted
}

public enum OpportunityType
{
    Donation,
    Grant,
    InKindGift,
    MajorGift,
    MatchingGift,
    Membership
}

[Icon(Svg = Icons.Opportunity)]
[Description("Opportunity Details")]
public class Opportunity : AuditBase
{
    [AutoIncrement]
    public int OpportunityId { get; set; }

    [Ref(Model = nameof(Associate), RefId = nameof(Associate.AssociateId), RefLabel = nameof(Associate.DisplayName))]
    [References(typeof(Associate))]
    public int? AssociateId { get; set; }

    [Reference]
    public Associate ? CurrentAssociate { get; set; }

    public string OpportunityName { get; set; } = default!;

    public OpportunityType OpportunityType { get; set; } = default!; 

    [IntlNumber(Currency = NumberCurrency.USD)]
    public decimal ? Amount { get; set; }

    [IntlDateTime(DateStyle.Long)]
    public DateTime ? CloseDate { get; set; }

    public OpportunityStage Stage { get; set; }

}

<AutoQueryGrid Model="Opportunity" Apis="Apis.AutoQuery<QueryOpportunityAutoQuery,CreateOpportunityAutoQuery,UpdateOpportunityAutoQuery>()"
               AllowSelection="true" AllowFiltering="true">

Any behavior or feature that can’t be defined decoratively would require using a custom form, some examples using EditForm.

1 Like