Web Forms for Marketers - Submit form data programmatically

泪湿孤枕 提交于 2019-12-04 18:54:30

If you don't want to dig into custom controls for the forms you might try performing a POST to a page that contains the WFFM form via JavaScript from your responsive page. Alternatively you could embed and hide the wffm form on your page and stunt drive it with script again. I think the second approach would be better as it would allow you to more directly respond to validation failures.

You could submit form code to the WFFM DB using the following code, and it would show up seamlessly in the report page of that form:

Say you have your list of fields populated in a list of this class:

public class WffmField
    {
        public string FieldName { get; set; }
        public string FieldGuid { get; set; }
        public string FieldValue { get; set; }
    }

the field guid would be the guid from sitecore:

You can then save to the WFFM database:

// This should be populated with the data you want to send to the WFFM database
var fields = new List<WffmField>(); 
var wffmDatabaseFields = fields.Select(GetWFFMDatabaseField).ToList();

Sitecore.Forms.Data.DataManager.InsertForm(
    formId: new Sitecore.Data.ID("<Form guid here>"),
    fields: new AdaptedResultList(wffmDatabaseFields),
    sessionID: AnalyticsTracker.SessionId,
    data: null);

Hope this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!