Try our conversational search powered by Generative AI!

Configure TinyMCE on FormContainerBlock submission email


I would like to enable the source code editor in TinyMCE for just the message field of the FormContainerBlock submission email. I don't see a way to do this since you can only configure interfaces of IContentData. I think the data type I'm trying to configure is the Body field of the EmailTemplateActorModel.

Below is a snippet from my TinyMCE configuration.

config.For<EmailTemplateActorModel>(t => t.Body)
  .Toolbar(new[] { defaultToolbarTop, "code" });

The error I get is: There is no implicit reference conversion from 'EPiServer.Forms.Implementation.Actors.EmailTemplateActorModel' to 'EPiServer.Core.IContentData'.    CapCom.Epi.Cms

Is there any way to accomplish this other than enabling the HTML souce code option for all editor fields?

Edited, Apr 20, 2023 21:24


The fastest way to overwrite the RTF settings for this specific field can be done using the EditroDescriptor:

    [EditorDescriptorRegistration(TargetType = typeof(XhtmlString))]
    public class EmailTemplateActorCollectionEditorDescriptor : EditorDescriptor
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
            base.ModifyMetadata(metadata, attributes);

            if (metadata.ContainerType == typeof(EmailTemplateActorModel))
                var settings = (TinyMceSettings)metadata.EditorConfiguration["settings"];
                //add any other settings

Since EmailTemplateActorModel doesn't inherit from IContentData, you need to override the behavior on the metadata. This is how it should look:

You can also be more specific and manipulate directly the EditorDescriptor that configures the EmailTemplateActorModel which is this: 

[EditorDescriptorRegistration(TargetType = typeof(IEnumerable<EmailTemplateActorModel>), UIHint = "EmailTemplateActorEditor")]
public class EmailTemplateActorCollectionEditorDescriptor : CollectionEditorDescriptor<EmailTemplateActorModel>

Hope it helps


Apr 27, 2023 17:05

Hi Santiago,

Thank you so much. Your code snippet works for modifying the editor descriptor for XhtmlString. When I adapt that to use the more specific selector for IEnumerable<EmailTemplateActorModel> I get errors when calling the base.ModifyMetadata(metadata, attributes) (adding duplicate key) and when accessing the metadata.EditorConfiguration["settings"] property (does not exist). Could you provide please the complete implementation for that specific registration?



Apr 28, 2023 14:49

After working with Optimizely support I had to tweak the attribute a bit to make this work.

[EditorDescriptorRegistration(TargetType = typeof(XhtmlString), EditorDescriptorBehavior = EditorDescriptorBehavior.PlaceLast)]

Once I deployed to the INTE environment I was seeing errors that I did not have locally and this solved that issue.

Also, I had to re-apply the TinyMCE configuration to include my default settings.

Jun 20, 2023 14:02

Hi Rich,

I don't suppose a blog post would be out of the question? to help share the knowledge and your experiences upon this.

Something brief that explains the situtation you where up against, what issues / errors you experienced along the way.

Who helped along the way.


Jun 21, 2023 10:26
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.