2

In the header html of our website we would like to insert a form, but it is not accessible from experience editor or content editor so I would like to insert it directly into the cshtml page for the header. I feel like it should be relatively simple, but have run into the wall.

I tried the below (but I really don't know what I'm doing) and it did not work.

@Html.Sitecore().Rendering("/sitecore/layout/Renderings/Modules/Web Forms for Marketers/Mvc Form", new {"formId","{11223344-5566-7788-9900-AABBCCDDEEFF}"})

I also tried:

@Html.Sitecore().RenderingItem("{11223344-5566-7788-9900-AABBCCDDEEFF}")

And I tried substituting the path for the id of the form.

1 Answer 1

1

Instead of passing FormId try to pass Data Source for the MVC form, like:

@Html.Sitecore().Rendering("{F2CCA16D-7524-4E99-8EE0-78FF6394A3B3}", new { DataSource = "{11223344-5566-7788-9900-AABBCCDDEEFF}" })

Where {F2CCA16D-7524-4E99-8EE0-78FF6394A3B3} is the WFFM MVC Form and {11223344-5566-7788-9900-AABBCCDDEEFF} is the WFFM form as a data source.

Update:

You will need to pass Unique Id of the form as below:

@Html.Sitecore().Rendering("{F2CCA16D-7524-4E99-8EE0-78FF6394A3B3}", new { Datasource = "<id of the form item>" , UniqueId = "<unique id of the form rendering>"})

reference: https://doc.sitecore.com/developers/90/web-forms-for-marketers/en/insert-a-web-form-directly-on-a-web-page.html

6
  • That generated a LOT of error messages. The root cause seemed to be this error: ...Message: uniqueId is empty Parameter name: uniqueId Source: Sitecore.Kernel at Sitecore.Diagnostics.Assert.ArgumentCondition(Boolean condition, String argumentName, String message) at Sitecore.Forms.Mvc.Models.FormModel..ctor(Guid uniqueId) at Sitecore.Forms.Mvc.Models.FormModel..ctor(Guid uniqueId, Item item)...
    – Michael
    Jun 5, 2020 at 15:26
  • @Michael, check the update section in the answer. Jun 5, 2020 at 15:41
  • Thank you @Mohammed Syam. How do I find that id in my instance?
    – Michael
    Jun 5, 2020 at 16:01
  • I believe it should be the wffm form Id. Jun 5, 2020 at 16:06
  • I'm glad it worked. Jun 5, 2020 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.