Copied to clipboard

Flag this post as spam?

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


  • Dem Muk 5 posts 106 karma points
    Dec 13, 2016 @ 09:32
    Dem Muk
    0

    How to render field inside Umbraco Form

    I have installed Umbraco form and now want to output the field content inside Form.cshtml as follows

    @Umbraco.Field("aboutUs")

    This keeps throwing errors. How do i go round this?

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Dec 13, 2016 @ 15:41
    Dennis Adolfi
    100

    Hi Dem Muk.

    So the reason you cant use the @Umbraco.Field is because Form.cshtml does not inherit UmbracoViewPage or UmbracoTemplatePage but instead it has a model of Umbraco.Forms.Mvc.Models.FormViewModel, so you cant get the UmbracoHelper without declaring it yourself.

    However, this can be done quite easy. Add this to the Form.cshtml file:

    @{
        var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
    }
    
    @(umbracoHelper.Field("aboutUs"))
    

    Best of luck to you!!

  • Dem Muk 5 posts 106 karma points
    Dec 14, 2016 @ 08:51
    Dem Muk
    1

    Hi Dennis Adolfi

    Thanks a lot. That fixed the problem.

  • Dennis Adolfi 1082 posts 6450 karma points MVP 6x c-trib
    Dec 14, 2016 @ 09:01
    Dennis Adolfi
    0

    Awesome Dem Muk!

    Glad it worked out for you!

    Best of luck with the rest of your site!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies