@using Microsoft.AspNetCore.Html
@using OrchardCore.ContentManagement
@using OrchardCore.Forms.Models
@using OrchardCore.Mvc.Utilities
@using OrchardCore.Workflows

@{
    var formPart = ((ContentItem)Model.ContentItem).As<FormPart>();
    string encType = formPart.Method == "POST" ? formPart.EncType : string.Empty;
    var formContentTypeClassName = "form-" + ((string)Model.ContentItem.ContentType).HtmlClassify();

    var elementId = ((ContentItem)Model.ContentItem).As<FormElementPart>()?.Id;
    string formId = string.IsNullOrWhiteSpace(elementId) ? $"form_{Model.ContentItem.ContentItemId}" : elementId;
}

<form id="@formId"
    action="@formPart.Action"
    method="@formPart.Method"
    enctype="@encType"
    class="@formContentTypeClassName"
    hx-post="@formPart.Action"
    hx-target="#form-step"
    hx-swap="outerHTML transition:true"
    hx-select="#form-step">
    @if (formPart.EnableAntiForgeryToken)
    {
        @Html.AntiForgeryToken()
    }

    @if (formPart.SaveFormLocation)
    {
        <input type="hidden" name="@WorkflowConstants.FormLocationKeyInputName" value="@ViewContext.HttpContext.Request.Path" />
    }

    @await DisplayAsync((IHtmlContent)Model.Metadata.ChildContent)
</form>
