I'm about to use umbraco forms in a project, but my customer wants a summary page of the data entered by the user before the user submit the form.
Is this possible? I did not find a way to do it with the GUI. I guess I have to hook up into the "page-process".
$("form").on("submit", function (e) {
e.preventDefault();// This will prevent form submit
var form = this;
var formData = $(this).serializeArray();
var html = GetFormDataInTable(formData)
$("#form-summary-modal").modal("show");// Bootstrap Model
$(".modal-body").html(html);
// Unbind Existing Click event
$("#btnSubmit").unbind("click");
$("#btnSubmit").click(function () {
//Submit Form
$.post($(form).attr("action"), $(form).serializeArray(), function (response) {
//process response here
$("#myModal").modal("hide");
$(form).find("[type='submit']").removeAttr("disabled");
alert(response);
})
})
$("#btnCancel").click(function () {
//Cancel Form Submit
$("#myModal").modal("hide");
$(form).find("[type='submit']").removeAttr("disabled");
})
return false;
})
function GetFormDataInTable(formData) {
// Create Table Element To Show Summary
var html = document.createElement("table");
html.setAttribute("class", "table");
//loop form field array
$.each(formData, function (i, v) {
if ($("[name=" + v.name + "]").is(":visible")) {
//append Each Form Field Data to table (only visible form fields)
$(html).append(GetFieldData(v));
}
})
return html;
}
function GetFieldData(field) {
var name = $("[name=" + field.name + "]").parent("div").siblings("label").text();
var value = field.value;
var tr = $("<tr><td>" + name + "</td><td>" + value + "</td></tr>");
return tr;
}
Note: I have considered default Umbraco Form Theme, to get Form Field Name.
Umbraco Forms - Summary Page
Hi,
I'm about to use umbraco forms in a project, but my customer wants a summary page of the data entered by the user before the user submit the form. Is this possible? I did not find a way to do it with the GUI. I guess I have to hook up into the "page-process".
Anyone any idea how to do this?
Thanks for your ideas.
Cheers,
Tom
You can use Jquery for the same, and show summary in Modal Popup.
You can do something like below.
I have used bootstrap modal to show summary.
Using jquery form submit method.
Note: I have considered default Umbraco Form Theme, to get Form Field Name.
Very good solution. Thank you for the code!
is working on a reply...