Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sitefinity Forms Popup window template
@model Telerik.Sitefinity.Frontend.Forms.Mvc.Models.FormViewModel
@using System;
@using System.Linq;
@using System.Collections;
@using Telerik.Sitefinity;
@using Telerik.Sitefinity.UI.MVC;
@using Telerik.Sitefinity.Frontend.Forms.Mvc.Helpers;
@using Telerik.Sitefinity.Frontend.Forms.Mvc.Models;
@using Telerik.Sitefinity.Frontend.Mvc.Helpers;
@using Telerik.Sitefinity.Modules.Pages;
@using Telerik.Sitefinity.Modules.Forms;
@{
var formTitle = "";
var isPopup = Model.CssClass.ToLower().Contains("modal") || Model.CssClass.ToLower().Contains("model") || Model.CssClass.ToLower().Contains("popup");
var css = Model.CssClass;
var title = "Contact Us";
if (Model.CssClass.ToLower().Contains("title-"))
{
var sections = Model.CssClass.Split('-');
title = sections.GetValue(1).ToString();
css = sections.GetValue(0).ToString().Replace(" title", "");
}
var thisForm = FormsManager.GetManager().GetForms().FirstOrDefault(f => f.Id == new Guid(Model.FormId) && f.Visible); //This should be in the model, but isn't
if(thisForm != null)
{
formTitle = thisForm.Title;
}
}
<div data-sf-role="form-container test" class="@css">
<input type="hidden" data-sf-role="form-id" value="@Model.FormId" name="FormId" />
@if (isPopup)
{
<input type="button" class="btn btn-primary btn-lg btn-block" value="@title" data-toggle="modal" data-target="#aform-@(Model.FormId)" />
@:<div class="modal fade" id="aform-@(Model.FormId)" tabindex="-1" role="dialog">
@:<div class="modal-dialog" role="document">
@:<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">@formTitle</h4>
</div>
@:<div class="modal-body">
}
@*DEFAULT SF FORM CODE START*@
@if (!string.IsNullOrEmpty(@ViewBag.ErrorMessage))
{
<div>@ViewBag.ErrorMessage</div>
}
@if (Model.UseAjaxSubmit)
{
<span data-sf-role="success-message" style="display: none;">@Model.SuccessMessage</span>
<span data-sf-role="error-message" style="display: none;"></span>
<img data-sf-role="loading-img" src='@Url.EmbeddedResource("Telerik.Sitefinity.Resources.Reference", "Telerik.Sitefinity.Resources.Themes.Default.Images.Loadings.sfLoadingData.gif")' style="display:none;" />
<div data-sf-role="fields-container">
@* Fields Markup *@
</div>
}
else
{
using (Html.BeginFormSitefinity("", null, (System.Web.Routing.RouteValueDictionary)null, FormMethod.Post, new Dictionary<string, object> { { "enctype", "multipart/form-data" } }, true))
{
@* Fields Markup *@
}
}
@if (Model.UseAjaxSubmit)
{
<input type="hidden" data-sf-role="ajax-submit-url" value="@Model.AjaxSubmitUrl" />
<input type="hidden" data-sf-role="redirect-url" value="@Model.RedirectUrl" />
@Html.Script(ScriptRef.JQuery, "jquery", false)
@Html.Script(Url.WidgetContent("Mvc/Scripts/Form/form-ajax.js"), "bottom", false)
}
@*DEFAULT SF FORM CODE END*@
@if (isPopup)
{
@:</div>
@:</div><!-- /.modal-content -->
@:</div><!-- /.modal-dialog -->
@:</div><!-- /.modal -->
}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.