Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

limo
Sep 28, 2017
  2572
(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
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog