The uHangout video alluded to being able to define your own Form.cshtml so you can get better control of the form's layout and styles. The video didn't say how in detail and it's not in the docs.
I want to add a very simple newsletter sign up box, single field, but all in line with some text in a particular section of a site's footer. The existing layout makes a mess of it so I want to build my own partial that fits in.
However, the original Form.cshtml will be fine for the two other forms on the site so I don't want to mess with that. I want to be able to define which view is to be used for which form.
That's the video I mentioned that only gives you half the details. I sorted the other half out now:-
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@if (Model.MacroParameters["FormGuid"] != null)
{
var s = Model.MacroParameters["FormGuid"].ToString();
var g = new Guid(s);
var v = Model.MacroParameters["View"].ToString();
Html.RenderAction("Render", "UmbracoForms", new {formId = g, mode = "form", view = v});
}
Which works once you add a macro parameter called "View" with a type of textbox.
Next problem is can we add new Fieldtypes? I need to add placeholder text into a text box so have copied Fieldtypes/FieldType.Text.cshtml but don't know where to register the new one so it becomes a choice in the Form creation grids. There will be another question after that, as I'll need a way of adding the text that is translatable. Dictionary item or some such ;)
Looking into what has to be done to add a View, then add a FieldType, with all the additional trial and error required, I'm thinking this is far too complicated and time consuming just to get an email address captured in a simple, single input form, embedded in a site footer. I'll just use normal MVC for this.
How to use own partial to output form
The uHangout video alluded to being able to define your own Form.cshtml so you can get better control of the form's layout and styles. The video didn't say how in detail and it's not in the docs.
I want to add a very simple newsletter sign up box, single field, but all in line with some text in a particular section of a site's footer. The existing layout makes a mess of it so I want to build my own partial that fits in.
However, the original Form.cshtml will be fine for the two other forms on the site so I don't want to mess with that. I want to be able to define which view is to be used for which form.
How do we go about that?
Thnx
Craig
Hi Craig,
Could it be this that you are looking for. http://youtu.be/iTKb4k4UJqU?t=18m10s Per shows how you can set the Forms, to use your own view.
Hope this helps,
/Dennis
Thanks Dennis,
That's the video I mentioned that only gives you half the details. I sorted the other half out now:-
Which works once you add a macro parameter called "View" with a type of textbox.
Next problem is can we add new Fieldtypes? I need to add placeholder text into a text box so have copied Fieldtypes/FieldType.Text.cshtml but don't know where to register the new one so it becomes a choice in the Form creation grids. There will be another question after that, as I'll need a way of adding the text that is translatable. Dictionary item or some such ;)
Craig
Hi Craig,
For how to add a new fileld types, I think that you should have a look on this documentation https://our.umbraco.org/documentation/Products/UmbracoForms/Developer/Extending/Adding-a-Fieldtype and https://our.umbraco.org/documentation/Products/UmbracoForms/Developer/Extending/Adding-a-Type
Hope this helps,
/Dennis
Refs:
https://our.umbraco.org/documentation/Products/UmbracoForms/Developer/Custom-Markup
https://our.umbraco.org/documentation/Products/UmbracoForms/Developer/Extending/Adding-a-Fieldtype
https://our.umbraco.org/documentation/Products/UmbracoForms/Developer/Extending/Adding-a-Type ;
Looking into what has to be done to add a View, then add a FieldType, with all the additional trial and error required, I'm thinking this is far too complicated and time consuming just to get an email address captured in a simple, single input form, embedded in a site footer. I'll just use normal MVC for this.
Cheers,
Craig
Hi Dennis,
Sorry, I didn't see your post before I posted mine (don't know why). Thanks for your help.
Craig :)
is working on a reply...