Visibility Conditions in the Widget Configuration Dialog?

Emily Hughes asked on July 5, 2019 16:58

In the widget configuration dialog, how can I make one field conditionally visible based on the value of another field? Consider the following widget properties:

public class MyWidgetProperties : IWidgetProperties
{
    [EditingComponent(CheckBoxComponent.IDENTIFIER, Label = "Check me", Order = 1)]
    public bool MyCheckbox { get; set; }

    // Only display this input if the checkbox is checked
    [EditingComponent(TextInputComponent.IDENTIFIER, Label = "Dependent text", Order = 2)]
    [EditingComponentProperty(nameof(TextInputProperties.VisibilityConditionConfiguration), 
    /* What object should be passed in here, or can another approach be taken? */ )]
    public string MyDependentTextInput{ get; set; }
}

I initially thought I could use the EditingComponentPropertyAttribute to set FormComponentProperties.VisibilityConditionConfiguration, but I suspect it isn't possible to set it within the attribute, since attribute parameters are restricted to constant values. I do also see the AnotherBoolFieldVisibilityCondition class, which sounds a lot like what I'm looking for, but perhaps that is not available in the context of the Widget Configuration Dialog (?).

So, how can I set up visibility rules within the configure window? Any guidance is greatly appreciated. Thanks!

Correct Answer

Leander Geldof answered on July 30, 2019 10:04

I contacted support and this is currently not possible; Help bring attention to this issue by voting for this Idea.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Dmitry Bastron answered on July 8, 2019 15:01

Hi Emily,

I've tried to complete your example and make it working but I was unable to find any solution to this. I see this kind of functionality is used in Form Builder only but not for Widget properties. You could write to support at support@kentico.com and ask them to provide a few examples how to coplete this. I believe this can help.

0 votesVote for this answer Mark as a Correct answer

Emily Hughes answered on July 30, 2019 16:43

Thanks Leander. I had the same experience (and they said I was not the first to ask for this), but my idea was never approved for display for whatever reason. I have voted for yours!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.