SaaS CMS has officially launched! Learn more now.

limo
Sep 28, 2017
  2615
(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
Optimizely London Dev Meetup 11th July 2024

On 11th July 2024 in London Niteco and Netcel along with Optimizely ran the London Developer meetup. There was an great agenda of talks that we put...

Scott Reed | Jul 19, 2024

Optimizely release SaaS CMS

Discover the future of content management with Optimizely SaaS CMS. Enjoy seamless updates, reduced costs, and enhanced flexibility for developers...

Andy Blyth | Jul 17, 2024 | Syndicated blog

A day in the life of an Optimizely Developer - London Meetup 2024

Hello and welcome to another instalment of A Day In The Life Of An Optimizely Developer. Last night (11th July 2024) I was excited to have attended...

Graham Carr | Jul 16, 2024

Creating Custom Actors for Optimizely Forms

Optimizely Forms is a powerful tool for creating web forms for various purposes such as registrations, job applications, surveys, etc. By default,...

Nahid | Jul 16, 2024

Optimizely SaaS CMS Concepts and Terminologies

Whether you're a new user of Optimizely CMS or a veteran who have been through the evolution of it, the SaaS CMS is bringing some new concepts and...

Patrick Lam | Jul 15, 2024

How to have a link plugin with extra link id attribute in TinyMce

Introduce Optimizely CMS Editing is using TinyMce for editing rich-text content. We need to use this control a lot in CMS site for kind of WYSWYG...

Binh Nguyen Thi | Jul 13, 2024