3

I am creating a custom dropdown field for WFFM (SC 8.1 MVC).

I've got it working nicely. However I am populating the data from an external API and I want to prevent content editors from thinking they can add Sitecore items to it from the form properties in the form designer.

enter image description here

My code ignores these items and clears them, but It's not a great user experience for content editors.

I'm inhering from droplist like so:

public class MyDropDownListWebForms : DropList
{
}

I've tried inheriting from ListControl or BaseUserControl instead but I don't want to loose all the properties, just the list items selection.

3

1 Answer 1

4

In order to remove the properties in the WFFM editor for custom fields, you need to inherit from your base control and then provide new implementations for the properties but do not specify any attributes.

To hide all fields in the List section you need to provide new implementations of all fields with [VisualCategory("List")] attribute set.

For example, you can hide the Items, Selected Value and Empty Choice properties by creating a custom field with the following implementation.

public class CustomDropList : Sitecore.Form.Web.UI.Controls.DropList
{
    public new ListItemCollection Items
    {
        get { return this.items; }
        set { this.items = value; }
    }

    public new string EmptyChoice
    {
        get { return false.ToString(); }
    }

    public new ListItemCollection SelectedValue
    {
        get { return this.selectedItems; }
        set { this.selectedItems = value; }
    }
}

When you create the item in Sitecore for your Custom Field, make sure Assembly and Class fields match your custom implementation. This is what is used in the form designer, even if your solution is using MVC. Be sure to specify the correct MVC Type as well though if required for the the front end.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.