Inside my Umbraco Forms generated e-mails I would like to hide fields that are not displayed because of active conditions.
For example: I want to show field 2 only if the condition is met and otherwise hide it in my e-mail. After a fit of coding i've found the .IsValid(form, string) method inside Umbraco.Forms.Core and start tweaking it.
var dictionary = new Dictionary<Guid, string>();
dictionary.Add(field.Id, string.Join(",", field.Values ?? new List<object>()));
var showField = field.Condition.IsVisible(form, dictionary);
But that isn't working as expected; all return values (showField) are false, even if they need to be true.
The FieldConditionEvaluation.IsVisible is expecting the Form and an dictionary (GUID, string) as parameter and can be found inside the namespace Umbraco.Forms.Core.
I've run into a similar issue where i want to display only the visible fields on a summary page. FieldConditionEvaluation.isVisible() is always false, there is also a method FieldConditionEvaluation.Test() which test the conditions but it doesn't take into consideration the visibility of the fields which the rules depend on, which Forms does. Eg if Field1 gets set to "Value1" and then the user goes back and changes input so Field1 is not not visible, then the Test() method will not take into consideration that this field is no longer visible.
The TestRule() has the same issue, but I have made my own method to take thsi into account. It requires that you make a dictionary 'allFields' with all the FieldViewModels, which i get from iterating through the FormViewModel gotten from the TempData.
Dictionary<string, FieldViewModel> allFields = new Dictionary<string, FieldViewModel>();
The method recursively tests the fields with the TestRule() method.
Umbraco Forms: hide conditional fields from email
Hi!
Inside my Umbraco Forms generated e-mails I would like to hide fields that are not displayed because of active conditions. For example: I want to show field 2 only if the condition is met and otherwise hide it in my e-mail. After a fit of coding i've found the .IsValid(form, string) method inside Umbraco.Forms.Core and start tweaking it.
And using it like this:
But that isn't working as expected; all return values (showField) are false, even if they need to be true.
The FieldConditionEvaluation.IsVisible is expecting the Form and an dictionary (GUID, string) as parameter and can be found inside the namespace Umbraco.Forms.Core.
Hey,
I've run into a similar issue where i want to display only the visible fields on a summary page. FieldConditionEvaluation.isVisible() is always false, there is also a method FieldConditionEvaluation.Test() which test the conditions but it doesn't take into consideration the visibility of the fields which the rules depend on, which Forms does. Eg if Field1 gets set to "Value1" and then the user goes back and changes input so Field1 is not not visible, then the Test() method will not take into consideration that this field is no longer visible.
The TestRule() has the same issue, but I have made my own method to take thsi into account. It requires that you make a dictionary 'allFields' with all the FieldViewModels, which i get from iterating through the FormViewModel gotten from the TempData.
The method recursively tests the fields with the TestRule() method.
Using Umbraco Forms 8.1.4
is working on a reply...