limo
Sep 28, 2017
  2715
(2 votes)

Programmatically move or hide Episerver Forms Actors in Edit View

The built-in "Send Email"-Actor in Episerver Forms lives on the Settings tab in Edit View by default.

My customer wanted to move everything to do with sending a form to a separate tab, including the actors, and hide the webhook actor. 

The only solution I found online was to do it from the Admin interface, but I wanted to do this programmatically to avoid having to change the property setting from Admin after deploy to our various environments.

I tried using an Editor Descriptor but could not quite get it to work, so I asked the Episerver Developer Support and got the following solution from them that worked perfectly:

[EditorDescriptorRegistration(
        TargetType = typeof(IEnumerable<EmailTemplateActorModel>), 
        UIHint = "EmailTemplateActorEditor",
        EditorDescriptorBehavior = EditorDescriptorBehavior.OverrideDefault)]
    public class EmailTemplateActorEditorDescriptor : CollectionEditorDescriptor<EmailTemplateActorModel>
    {
        public EmailTemplateActorEditorDescriptor()
        {
            ClientEditingClass = "epi-forms/contentediting/editors/EmailTemplateActorEditor";
        }
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            GridDefinition.GridSettings["richTextColumns"] = new[] { "body" };

            base.ModifyMetadata(metadata, attributes);

            metadata.GroupName = GlobalSettings.GroupNames.SendTab;
            metadata.Order = 50;

            //...if you want to hide the actor, set metadata.ShowForEdit = false;
        }
    }

(The Send Email actor contains a rich text editor, which is why the GridDefinition settings are needed when overriding the Metadata function above.)

I hope this can help others that would like to do the same thing.

Sep 28, 2017

Comments

Please login to comment.
Latest blogs
Recraft's image generation with AI-Assistant for Optimizely

Recraft V3 model is outperforming all other models in the image generation space and we are happy to share: Recraft's new model is now available fo...

Luc Gosso (MVP) | Nov 8, 2024 | Syndicated blog

ExcludeDeleted(): Prevent Trashed Content from Appearing in Search Results

Introduction In Optimizely CMS, content that is moved to the trash can still appear in search results if it’s not explicitly excluded using the...

Ashish Rasal | Nov 7, 2024

CMS + CMP + Graph integration

We have just released a new package https://nuget.optimizely.com/package/?id=EPiServer.Cms.WelcomeIntegration.Graph which changes the way CMS fetch...

Bartosz Sekula | Nov 5, 2024

Block type selection doesn't work

Imagine you're trying to create a new block in a specific content area. You click the "Create" link, expecting to see a CMS modal with a list of...

Damian Smutek | Nov 4, 2024 | Syndicated blog