I'm using FormFlow and would like to automatically populate some of the next fields based on the answers.
For instance in the following code, if a user answers the question of CloudType with NationalCloud I would like to automatically set the value of ClusterPurpose to 1 and not to ask for it's value. In case a user answer CloudType with PublicCloud I would like to ask for the ClusterPurpose.
What is the best way to achieve this?
public static IForm<MyForm> BuildForm()
{
var customFormBuilder = CreateCustomFormBuilder<MyForm>();
return customFormBuilder
.Field(nameof(CloudType))
.Field(nameof(NationalCloudType), active: state => !IsPublicCloudChosen(state))
.Field(nameof(ClusterPurpose))
.CompleteRequestForm();
}
}
Thanks!
You can set state.ClusterPurpose when validating CloudType input and hide ClusterPurpose field if state.CloudType is NationalCloud.