0

I want to set the form fields like name and email from data though url query string . I have rendered the form through macro . how i can do that my macro rendering code is

@Umbraco.RenderMacro("renderUmbracoForm", new {FormGuid="ccebfbe8-aa28-497e-8078-c3577c88f47a", FormTheme="" ,
 ExcludeScripts="0"} )

My form fields are Name, Email , EventName form pic and url query is

http://localhost:17402/register?eventId=1342&eventName=you%20cant%20save%20the%20world%20alone

Asad
  • 3,070
  • 7
  • 23
  • 61

1 Answers1

1

In Umbraco Forms, you can set the Default Value of a field.

enter image description here

For example, set the Default Value to something like [@queryName]. The 'queryName' will be your querystring parameter name in the URL (http://www.website.com/contactus?queryName=Foo) - Umbraco does the rest.

I referred to this and it was pretty straight forward: https://our.umbraco.org/forum/umbraco-pro/contour/14340-Set-value-of-radiobuttonlist-from-querystring

DT-UK
  • 21
  • 5
  • what if that param not present in url but in razor variable like var a=123; @DT – Asad Jan 23 '18 at 11:35
  • I'm not sure, via querystring is the only way I've known this functionality to work so I'd recommend doing a small test case to see if this works as you would want it to. A work around would be to ensure that the value (123) is available earlier on in the process to put in the querystring from there you can pass it to the razor variable (if you must). If, however, this sensitive information you don't want in the URL, there may be other ways around it e.g. re-reading that article I linked you to it seems you can try such as SessionKey (%). Hope you find a fix! – DT-UK Feb 28 '18 at 22:47