I have also experienced this problem, where I don't know where I should place the custom form files.
/views/partials/forms/{GUID}/Form.cshtml - also seems as the logical place for me to put the custom files, just as you did in Contour.
Davids solution for the InsertUmbracoForm.cshtml MacroPartial, works perfect, but what if you just wanted to make a simple change to FieldType.Textfield.cshtml for a single form?
From inspecting the decompiled code for Contour I am led believe that the field type should work - I have not needed to do this, but I can see code checking for a file at the below location:
I think I have located the error FieldViewResolver:
public static string GetFieldView(string formAlias, string viewName, string fieldName)
{
if (fieldName.Length > 75)
{
fieldName = fieldName.Substring(0, 75);
}
viewName = FieldViewResolver.FolderName(viewName);
string result;
if (File.Exists(HttpContext.Current.Server.MapPath(string.Format("{0}/Forms/{1}/Fieldtype.{2}.cshtml", Config.ViewsPath, formAlias, viewName))))
{
result = string.Format("{0}/Forms/{1}/Fieldtype.{2}.cshtml", Config.ViewsPath, formAlias, viewName);
}
else
{
result = string.Format("{0}/FieldTypes/Fieldtype.{1}.cshtml", Config.ViewsPath, viewName);
}
return result;
}
The config.viewsPath is "~/Views/Partials/Forms"
Which makes the first check "~/Views/Partials/Forms/Forms/{GUID}/FieldType.Textfield.cshtml"; otherwise it returns "~/Views/Partials/Forms/{GUID}/FieldType.Textfield.cshtml"
Good spot Soren - I guess you need to flag that as a bug to Umbraco so that path can be resolved in a future release (I assume it isnt meant to be /Forms/Forms/
Just a follow up as to how we have used this, we have a view that allows forms to be added to a drop down at the top of the page, we needed these to be formatted differently to those forms that are used within the body of a content page, rather than using the Form ID we have just used the following so all the forms used in the drop downs use the same form view, all others use the standard form view.
var customFile = "/Views/Partials/Forms/DropDownForms/Form.cshtml";
var view = (System.IO.File.Exists(Server.MapPath(customFile))) ? customFile : "";
Html.RenderAction("Render", "UmbracoForms", new { formId = g, view });
Thanks to this thread as I couldn't find any documentation about this functionality, in-fact there is another thread that mentions this is currently not possible, so I can confirm as of the current version 4.1.4 it is possible :)
Umbraco 7.2.1 - Forms - Custom Layout
Hi,
I have followed the instructions for customising a single form layout in Forms (was Contour) as shown here:
http://our.umbraco.org/projects/umbraco-pro/contour/documentation/Developer/Custom-Markup/
Obviously the path is now different and I assume it is: /views/partials/forms/{GUID}/Form.cshtml
This however does nothing and it still renders the Form.cshtml in the root of the views/partials/forms/ folder.
I have triple checked the GUID is correct.
Can anyone confirm this actually works in 7.2.1 now that Forms are built into Umbraco?
Any help is much appreciated.
Regards Dave
Hi Dave
Do you have any kind of caching setup, which might be the issue? Does it help if you recycle the app pool?
/Jan
Yeah I have tried:
Can you check whether this works for you in 7.2.1?
Thanks for your reply
Dave
Ok, I've managed to get it working but I had to decompile the dll the figure it out. The code that checks for the override view is:
Where view is a string passed into the Render Action on the UmbracoForms Controller and the Config.ViewsPath = "~/Views/Partials/Forms".
The "view" string is built up anywere, just passed in, so I edited the InsertUmbracoForm.cshtml MacroPartial to do:
This is now functioning correctly.
I don't know whether I have missed something obvious but this is the only way I can get this to work.
Any advice/comments are appreciated.
Cheers
Hi,
I have also experienced this problem, where I don't know where I should place the custom form files.
/views/partials/forms/{GUID}/Form.cshtml - also seems as the logical place for me to put the custom files, just as you did in Contour.
Davids solution for the InsertUmbracoForm.cshtml MacroPartial, works perfect, but what if you just wanted to make a simple change to FieldType.Textfield.cshtml for a single form?
Thanks in advance
/Soren
Hi Soren,
Glad my solution works for you.
From inspecting the decompiled code for Contour I am led believe that the field type should work - I have not needed to do this, but I can see code checking for a file at the below location:
/views/partials/forms/{GUID}/FieldType.Textfield.cshtml
Let me know if it works for you.
Cheers
Hi
Thank you for the fast response.
I think I have located the error FieldViewResolver:
The config.viewsPath is "~/Views/Partials/Forms"
Which makes the first check "~/Views/Partials/Forms/Forms/{GUID}/FieldType.Textfield.cshtml"; otherwise it returns "~/Views/Partials/Forms/{GUID}/FieldType.Textfield.cshtml"
/Soren
Good spot Soren - I guess you need to flag that as a bug to Umbraco so that path can be resolved in a future release (I assume it isnt meant to be /Forms/Forms/
Cheers
Hi Guys,
Just a follow up as to how we have used this, we have a view that allows forms to be added to a drop down at the top of the page, we needed these to be formatted differently to those forms that are used within the body of a content page, rather than using the Form ID we have just used the following so all the forms used in the drop downs use the same form view, all others use the standard form view.
Thanks to this thread as I couldn't find any documentation about this functionality, in-fact there is another thread that mentions this is currently not possible, so I can confirm as of the current version 4.1.4 it is possible :)
Okay it's May 2016 and this bug is still there!
Thanks David for your fix, this was driving me nuts for a while.
is working on a reply...