Fluent API Form Examples?
Could you give a few examples on how to use the Fluent API with forms?
Queries needed:
- List of form names
- List of form entries for a particular form
Thanks,
Michael Snyder
ConnectionsAcademy.com
Hi ,
You have to use the standard API to get these results.
FormsManager manager = FormsManager.GetManager();
var forms = manager.GetForms();
foreach (FormDescription d in forms)
var title = d.Title;
var name = d.Name;
To get the response of a form you can use
public IEnumerable GetFormEntries(Type entryType, string filter, string orderBy, int skip, int take, ref int? count)
Greetings,
Ivan Dimitrov
the Telerik team
Hi,
How do I add a value using Fluent API to the Form I created in CMS?
Hi Zubair,
Here is the programmatic way to add a new entry to a form
IManager manager;
manager = FormsManager.GetManager(providerName);
using
(var fluent = App.WorkWith())
var facade = fluent.Forms().Form(formName);
facade.Do(fd =>
fd.FormEntriesSeed++;
entry.Item.ReferralCode = fd.FormEntriesSeed.ToString();
);
entry.Item.SubmittedOn = DateTime.UtcNow;
entry.Item.UserId = SecurityManager.GetCurrentUser().UserId;
this
.SetEntryIpAddress(entry.Item);
manager.SaveChanges();
ServiceUtility.DisableCache();
Hi,
This is incomplete code and it breaks, can you please include full code with namespaces and also tell me how to add value for each form field?
Thanks,
Hi,
Any news?
Hi Zubair,
Have you specified the form name for which you want to add a new entry? You can get a refernce to the classes through Visual Studio Intellisense. It should shows you the missing reference in your class.
Best wishes,
Ivan Dimitrov
the Telerik team
I know I can add a FormName but I cant find out the how the entry will look like, anyway I will look at this post to do the same.
@Ivan
In your code posted on June 20th you are adding the "entry" data. Where and how are you setting this up?
entry.Item.SubmittedOn = DateTime.UtcNow;
entry.Item.UserId = SecurityManager.GetCurrentUser().UserId;
this
.SetEntryIpAddress(entry.Item);
manager.SaveChanges();
ServiceUtility.DisableCache();
I have tried to add a form entry using the sample code and it doesn't work on my end. Do you guys have a full sample in the SDK?
Brett
@Brett,
I got this to work with the help of this post, though I changed it from extension method to a 'normal' method
www.sitefinity.com/.../how-to-use-createformentry.aspx
Telerik/Sitefinity team isn't helping :(
Hello,
There is also FormEntriesFacade which could be used to get IQueryable<FormEntry>
Best wishes,
Ivan Dimitrov
the Telerik team
What are references are needed for this formsmanager.
Thanks
Naman
If you want to use FormsManager, you need to add this using:
using
Telerik.Sitefinity.Modules.Forms;
Now what reference and dll is required for formsDescription ????
reference to Telerik.Sitefinity.dll
Still Getting Error for FormDescription ???
I cannot read your mind. Please give me more details. What is the error, your code and etc
FormsManager manager = FormsManager.GetManager();
var forms = manager.GetForms();
foreach (FormDescription d in forms)
var title = d.Title;
var name = d.Name;
return View();
Same code I am using but on this line :-
foreach (FormDescription d in forms)
getting error that FormDescription could not found (are you missing a using directive or an assembly reference) ???
add reference to Telerik.Sitefinity.Model.dll
I am not sure why, you have missing references to this basic dlls in your project
Thanks Its working now :)
Hi I need to ask if i am using this code in different application to get the form list from any website so how to pass website url in this code so can we get forms for that particular website. ?