umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
29 stars 0 forks source link

Form not appearing on template #1166

Closed Jamaalkho closed 7 months ago

Jamaalkho commented 7 months ago

Hello, I'm new to umbraco, i'm trying to integrate a form on a contact page. Using the form plugin, i have created a macro contact-form with parameters

macro

And adding this code into my template :

`@inherits Umbraco.Web.Mvc.UmbracoViewPage @using ContentModels = Umbraco.Web.PublishedModels; @using Umbraco.Forms.Mvc @{ Layout = "master.cshtml"; }

@Umbraco.RenderMacro("innerBanner", new {crop="full"}) @Umbraco.RenderMacro("breadcrumb")

@Umbraco.RenderMacro("contactForm", new {formName="d5056b9d-70d3-4a6b-8d75-c5e81ed86452", formTheme="bootstrap3-horizontal"}) ` I don't know why i'm doing wrong here. Any idea please?

Thanks

AndyButland commented 7 months ago

You haven't mentioned what version you are running, but assuming you are on 10 or up, the documentation for rendering forms is here.

If you are on Forms 8, you'll need to look at the legacy documentation, which can be found here.

Here's a couple of very basic template samples for rendering a form that may help too. They both assume you have a property on your document type with an alias of form and a type of "Form Picker".

For Forms 10+:

@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;
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
@if (Model.Form.HasValue)
{
    @await Component.InvokeAsync("RenderForm", new { formId = Model.Form, theme = "default", includeScripts = true })
}
@Html.RenderUmbracoFormDependencies()
</body>
</html>

And Forms 8:

@inherits UmbracoViewPage<HomePage>
@using Umbraco.Forms.Mvc
@using ContentModels = Umbraco.Web.PublishedModels;

<!DOCTYPE html>
<html>
<head>
</head>
<body>
@Umbraco.RenderMacro("renderUmbracoForm", new { FormGuid = Model.Form })
@Html.RenderUmbracoFormDependencies()
</body>
</html>
Jamaalkho commented 7 months ago

Thanks, working...