Closed Namrata-V2 closed 3 months ago
I'm not sure what the issue is here but I'd suggest just to simplify things a bit, try rendering the form directly on the template without the complications of the rich text editor and macro.
And then use a simple template like the following (assumes you have a doc type with a form picker property called "Form").
@using Umbraco.Cms.Web.Common.PublishedModels;
@using Umbraco.Forms.Web;
@using Umbraco.Forms.Web.Extensions;
@using Umbraco.Cms.Core.Configuration.Models;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.HomePage>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@{
Layout = null;
}
<html>
<head>
<title>Sample Form Page</title>
</head>
<body>
<h1>Sample Form Page</h1>
@if (Model.Form.HasValue)
{
@await Component.InvokeAsync("RenderForm", new { formId = Model.Form, theme = "default", includeScripts = true })
}
@Html.RenderUmbracoFormDependencies()
</body>
</html>
Thanks @AndyButland for your response.
As per your suggestion. I have created a template
Views/ReCaptchaEnterprise.html
@using Umbraco.Cms.Web.Common.PublishedModels;
@using Umbraco.Forms.Web;
@using Umbraco.Forms.Web.Extensions;
@using Umbraco.Cms.Core.Configuration.Models;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.ReCaptchaEnterprise>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@{
Layout = null;
}
<html>
<head>
<title>Sample Form Page</title>
</head>
<body>
<h1>Sample Form Page</h1>
@await Component.InvokeAsync("RenderForm", new { formId = Guid.Parse(<guid>), theme = "default", includeScripts = true })
@Html.RenderUmbracoFormDependencies()
</body>
</html>
and then created a Content ReCaptchaEnterprise using the same template and published the content.
When I check https://localhost:44326/recaptcha-enterprise/
It throws the exception mentioned in the original post.
This is what the ReCaptchaEnterprise.generated.cs looks like :
namespace Umbraco.Cms.Web.Common.PublishedModels
{
/// <summary>ReCaptcha Enterprise</summary>
[PublishedModel("reCaptchaEnterprise")]
public partial class ReCaptchaEnterprise : PublishedContentModel
{
// helpers
#pragma warning disable 0109 // new is redundant
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "12.0.1+20a4e47")]
public new const string ModelTypeAlias = "reCaptchaEnterprise";
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "12.0.1+20a4e47")]
public new const PublishedItemType ModelItemType = PublishedItemType.Content;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "12.0.1+20a4e47")]
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
public new static IPublishedContentType GetModelContentType(IPublishedSnapshotAccessor publishedSnapshotAccessor)
=> PublishedModelUtility.GetModelContentType(publishedSnapshotAccessor, ModelItemType, ModelTypeAlias);
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "12.0.1+20a4e47")]
[return: global::System.Diagnostics.CodeAnalysis.MaybeNull]
public static IPublishedPropertyType GetModelPropertyType<TValue>(IPublishedSnapshotAccessor publishedSnapshotAccessor, Expression<Func<ReCaptchaEnterprise, TValue>> selector)
=> PublishedModelUtility.GetModelPropertyType(GetModelContentType(publishedSnapshotAccessor), selector);
#pragma warning restore 0109
private IPublishedValueFallback _publishedValueFallback;
// ctor
public ReCaptchaEnterprise(IPublishedContent content, IPublishedValueFallback publishedValueFallback)
: base(content, publishedValueFallback)
{
_publishedValueFallback = publishedValueFallback;
}
// properties
}
}
I think the problem might be in your FieldType.ReCaptchaEnterprise.html
.
You have this line:
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage
But we don't have that in the documentation for the partial view. We just have a @model
. Try removing this as that looks to be related to the error you are seeing.
Thanks a ton, @AndyButland. It indeed resolved the issue.
Recently, I found that Umbraco doesn't have an option to support the enterprise invisible reCaptcha. After following a bit along I did came across this documentation where we can create custom field type and have a custom validation logic.
What I have done so far :
Add a new class
ReCaptchaEnterprise.cs
Partial View
FieldType.ReCaptchaEnterprise.html
Umbraco backoffice view
App_plugins/UmbracoFotms/backoffice/Common/FieldTypes/ReCaptchaEnterprise.html
I am able to add the reCaptcha enterprise in the form. However, when I go to Content and add it over there via
Rich Text Editor > Macro
the following exception is thrown.A complete stacktrace:
I have followed other packages that tried to perform something similar to implement reCaptcha but I cannot find anything that is being missed out.
I have no idea what is going wrong here I am debugging the issue since last week and cannot find any solution.
I will really appreciate any leads to resolve this issue or if you can share your experience with similar feature. Thank you so much for your time for reading through my question until here.