Copied to clipboard

Flag this post as spam?

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


  • Nidhi 34 posts 156 karma points
    Sep 08, 2023 @ 00:52
    Nidhi
    0

    Umbraco Forms 11.2 default theme location and how to render custom theme

    Hi

    We are using Umbraco form 11.2 and having issue rendering our custom theme. So we created a form using Umbraco Forms and we are trying to render using the following.

    @(await Component.InvokeAsync("RenderForm", new { formId = new Guid(formId), recordId = Guid.Empty, theme = "my-theme", includeScripts = false }))
    

    We have created a separate themes folder under Forms themes. We also tried to set the themes to default and then made some test changes to the class in default form file but it doesn't update the class on the front-end even to the default inside the Forms themes folder. I suppose Umbraco forms 11 doesn't have Applugins folder as well. So where is the default theme location. And how can we point it to our custom one.

    Any help will be appreciated.

    Thanks

  • Marc Goodson 2157 posts 14411 karma points MVP 9x c-trib
    Sep 10, 2023 @ 09:06
    Marc Goodson
    0

    Hi Nidhi

    I have a custom theme working in the location

    /views/Partials/Forms/Themes/ThemeName

    and on a Form Page which I've added a Form Picker to, I render it like this:

      @await Umbraco.RenderMacroAsync("renderUmbracoForm", new {FormGuid=Model.FormToDisplay, FormTheme="ThemeName", ExcludeScripts="0"})
    

    (My Form Picker field is called 'FormToDisplay')

    This uses the approach of reusing the Macro called 'Insert Form With Theme' that Umbraco Forms ships with...

    But you should also be able to use a TagHelper or a ViewComponent, according to the docs:

    https://docs.umbraco.com/umbraco-forms/developer/rendering-forms

    Be interesting to see if you used the Macro approach like I have, whether your theme is picked up! and it's the ViewComponent approach where you have the issue, or whether it's all approaches!!!

    regards

    marc

  • Nidhi 34 posts 156 karma points
    Sep 11, 2023 @ 19:16
    Nidhi
    0

    Hi Marc

    Thanks for your response. I am using the form picker in a Form Block and when i use

     @await Umbraco.RenderMacroAsync("renderUmbracoForm", new {FormGuid=Model.FormToDisplay, FormTheme="ThemeName", ExcludeScripts="0"})
    

    i get the error

    Could not locate template for type FormBlock, expected file ~/Views/Elements/FormBlockView.cshtml and when i use tag helper no form is shown.

    Looks like there is something i am missing when i use rendermacroasync, where should the template be located any idea?

    So basically none of the approaches are working for me. RenderForm- form working but theme not picked RenderMacroAsyn- throwing template error as above. Taghelper- form not working.

    Thanks

    Nidhi

  • Nidhi 34 posts 156 karma points
    Sep 13, 2023 @ 00:04
    Nidhi
    101

    The themes with Viewcomponent is working for me now. I kept the themes files at the incorrect path. I had Themes inside Themes. I have corrected that and themes are working now.

Please Sign in or register to post replies

Write your reply to:

Draft