This project is read-only.

Use Querystring in custom form template editor?

Topics: General
Apr 10, 2013 at 3:24 PM
I am new to Orchard. I have a custom form I created for customers to submit when we are out of stock on an item and they want to be notified when we get more in. The custom form is called "OutOfStock", the content type is called "OutOfStockForm". The fields are Name (input), Email (input), ItemName (input), Country (enumerable), and State (enumerable). In the url to get to the form I am passing the item name as "&itemname=FaxMachine3542" (for example).

How/where can I pull the itemname into my ItemName input field on my custom form so that it is entered for my customer. I need it in the submission. Could I put this into an alternate template on the field? If so how?

I have alternate editor template for the field called "EditorTemplate-OutOfStock.ItemName.cshtml", but haven't been able to figure out anything that works. Please help!
Apr 10, 2013 at 10:10 PM
You could create a view for one of the ItemName input shape alternates directly, for example: Fields.Input-ItemName.cshtml. You'll be able to retrieve the querystring value from here and use it to render the value attribute of the input field.

Perhaps you are already familiar with it, but in case you aren't: the Shape Tracing feature helps a lot when finding out about shapes and alternates.
Also be sure to check out the docs on shapes, templates and alternates.