We are trying to hide some form field based on some condition but the existing Rules Action hides the filed from the server side.
We will be storing some value in field and these values will be submitted with form submission and it will come on the report.
Is there any way to hide field on client side with the help of WFFM personalization rules/action?
Any small code or reference will help.
1 Answer
I got the solution to my problem -
We have added a custom action and registered this action under
/sitecore/system/Settings/Rules/Definitions/Elements/Web Forms for Marketers Actions
public class HideFormControl<T> : Sitecore.Forms.Core.Rules.ReadValueFromQueryString<T> where T : Sitecore.Forms.Core.Rules.ConditionalRuleContext
{
public HideFormControl()
{
}
public override void Apply(T ruleContext)
{
Assert.ArgumentNotNull(ruleContext, "ruleContext");
if (ruleContext.Model != null && ruleContext.Model is FieldViewModel)
{
FieldViewModel field = ((FieldViewModel)ruleContext.Model);
field.Visible = false;
}
}
}