Now I need to use the content service to set the value in backoffice, but I cant seem to do it for the dropdown fields. here is my controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using System.Text;
using System.Net.Mail;
using Ankur_Stellar.Models;
using Ankur_Stellar.Helpers;
namespace Ankur_Stellar.Controllers
{
public class WarrantySurfaceController : SurfaceController
{
private PreValueHelper preValueHelper => new PreValueHelper();
public ActionResult ShowForm()// links controller to template/macro
{
WarrantyModel myModel = new WarrantyModel();
myModel.InstallTypes = preValueHelper.GetPreValuesFromAppSettingName("InstallTypeDropdown");
myModel.Applications = preValueHelper.GetPreValuesFromAppSettingName("ApplicationDropdown");
myModel.PurchasedFroms = preValueHelper.GetPreValuesFromAppSettingName("PurchasedDropdown");
return PartialView("WarrantyForm", myModel); // Links to Partial View
}
public ActionResult HandleFormPost(WarrantyModel model) //Links functions to the form in the partial view...BeginUmbracoForm
{
if (ModelState.IsValid) // For Field Validation
{
// This will post submittion to Umbraco Database
var newWarranty = Services.ContentService.CreateContent(model.WarLastName + "-" + DateTime.Now, 1204, "warrantyFormula");
var myService = ApplicationContext.Services.DataTypeService;
newWarranty.SetValue("WarInstallDate", model.WarInstallDate);
newWarranty.SetValue("WarSqFt", model.WarSqFt);
newWarranty.SetValue("WarInstallType", need the selected value of the dropdown);
newWarranty.SetValue("WarApplication", model.Applications);
newWarranty.SetValue("WarColor", model.WarColor);
Services.ContentService.SaveAndPublishWithStatus(newWarranty);
catch (SmtpException)
{
TempData["Failed"] = true;
return RedirectToCurrentUmbracoPage();
}
TempData["Success"] = true;
return RedirectToCurrentUmbracoPage();
}
TempData["Failed2"] = true;
return RedirectToCurrentUmbracoPage();
}
}
}
Post selected dropdown data on a form back to backoffice
Hello All, Thanks in advance.
I Have created a form with a few dropdown selections. and I need to post the selected value back to the document type in backoffice.
I created the form with the dropdowns from this tutorial.:http://www.codeshare.co.uk/blog/how-to-use-an-umbraco-data-type-to-populate-an-mvc-drop-down-list/... which uses a helper to generate the dropdown options from a datatype and display it on the form.
Now I need to use the content service to set the value in backoffice, but I cant seem to do it for the dropdown fields. here is my controller:
is working on a reply...