Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stephen 26 posts 148 karma points
    Jun 16, 2022 @ 02:34
    Stephen
    0

    Umbraco Forms 9+ Rich Text

    I'd like to display some rich text between questions in an Umbraco Form.

    An example use case would be to render a hyperlink to supporting documentation, or to a privacy policy above the submit button.

    There are forum threads and even a package to achieve this for Umbraco versions 7 and 8, but I've not found anything for Umbraco 9 and up.

    Following the documentation on creating an Umbraco Forms custom field type I have created a custom field type with a working setting field to populate and render, but I'm stuck on how to enhance this with the Umbraco 9 rich text editor.

    Any pointers or examples on how to do this?

  • Aaron 58 posts 406 karma points MVP 2x c-trib
    Jun 23, 2022 @ 14:59
    Aaron
    100

    I've just spoken to Matthew (the author) I will work on a PR for V9 and V10 for the Umbraco Forms Rich Text Editor package =]

  • Stephen 26 posts 148 karma points
    Jun 26, 2022 @ 22:03
    Stephen
    0

    That's awesome, thank you!

    For future thread visitors:

    Umbraco Forms Rich Text package (now with version 3.0.0-alpha for Umbraco 10):

    https://our.umbraco.com/packages/backoffice-extensions/umbraco-forms-rich-text/

    The package source code:

    https://github.com/Matthew-Wise/umbraco-forms-rte

  • Stephen 26 posts 148 karma points
    Oct 04, 2022 @ 19:56
    Stephen
    0

    An update for any future readers: As of Umbraco Forms versions 9.5 and 10.1, there is now a rich text field included out of the box!

    https://umbraco.com/blog/umbraco-forms-81395101-release/

  • ianhoughton 281 posts 605 karma points c-trib
    Dec 13, 2022 @ 20:27
    ianhoughton
    0

    Hi Stephen, have you tried the latest version? I've added it to a form and am rendering the content with:

    @inject HtmlLocalLinkParser HtmlLocalLinkParser;
    @inject HtmlUrlParser HtmlUrlParser;
    @inject HtmlImageSourceParser HtmlImageSourceParser;
    
    @{
        if (Model.AdditionalSettings.TryGetValue("Html", out var value))
        {
            value = HtmlLocalLinkParser.EnsureInternalLinks(value);
            value = HtmlUrlParser.EnsureUrls(value);
            value = HtmlImageSourceParser.EnsureImageSources(value);
    
            <div id="@Model.Id">
                @Html.Raw(value)
            </div>
        }
    }
    

    both of them are rendering the link with a url to the root of the site. Checking the value, i can see that the url being passed into Html.Raw is already href="/". It looks like the url or locallink is being stripped out of the version of the RTE being used in forms?

  • Stephen 26 posts 148 karma points
    Dec 14, 2022 @ 20:12
    Stephen
    0

    Hi Ian, I've not used the latest version yet.

    The solution this question was regarding is currently using Umbraco.Cms 10.2.0 and Umbraco.Forms 10.1.2. Using the default rich text field template, it works as expected when creating hyperlinks:

    @model Umbraco.Forms.Web.Models.FieldViewModel
    @using Umbraco.Forms.Web
    
    @inject Umbraco.Cms.Core.Templates.HtmlLocalLinkParser htmlLocalLinkParser;
    
    @{
        string value;
        if (Model.AdditionalSettings.TryGetValue("Html", out value))
        {
            <div id="@Model.Id" data-umb="@Model.Id" class="@Html.GetFormFieldClass(Model.FieldTypeName)">
                @Html.Raw(htmlLocalLinkParser.EnsureInternalLinks(value))
            </div>
        }
    }
    

    Might be worth creating a new question for better visibility of your issue?

Please Sign in or register to post replies

Write your reply to:

Draft