I have created a Macro Parameter for the Formulate Form Picker. This works fine and I can get the form Id back from the Macro Parameter. I now need to get a ConfiguredFormInfo model from that Form Id. Has any one done this? Or does Formulate have any helpers I can use?
It's been a while, but it looks like I got Formulate working with a macro (in this case, on a WebForms project, but should translate well to Razor). I suppose this is the most relevant bit of code you'll want to focus on:
// Variables.
var context = Umbraco.Web.UmbracoContext.Current;
var content = context.PublishedContentRequest.PublishedContent;
// Get a view model for the picked form.
var pickedForm = Umbraco.Web.PublishedContentExtensions
.GetPropertyValue<formulate.app.Types.ConfiguredFormInfo>(content, "contactForm");
var vm = formulate.api.Rendering.GetFormViewModel(pickedForm.FormId, pickedForm.LayoutId,
pickedForm.TemplateId, content);
// Pass form model to user control.
formRenderer.FormModel = vm;
I just can't get the ConfiguredFormInfo Model at all. All I get back from the Macro Parameter is the Id of the Form nothing else. And then I cant seem to get the form using the ID what so ever. I might have to change the way I am using the Form Picker and move it away from the Macro and just put it onto the Document Type itself and just use the Macro to display the form.
I might have to change the way I am using the Form Picker and move it away from the Macro and just put it onto the Document Type itself and just use the Macro to display the form.
I personally don't use Umbraco macros and wouldn't recommend them, unless you're using Umbraco Grid (which are a different type of macro).
But putting the form picker property on the doctype itself would be a fine approach too.
Im using App Data models this wouldnt affect it would it?
Not sure what you mean by "App Data models". Are you using Models Builder and the C# classes for the models are placed in the App_Data folder? If so, I imagine that'd be fine, but I haven't tried combining models builder and Formulate before. Worth a shot.
Formulate Get ConfiguredFormInfo By Form Id
Hi,
I have created a Macro Parameter for the Formulate Form Picker. This works fine and I can get the form Id back from the Macro Parameter. I now need to get a ConfiguredFormInfo model from that Form Id. Has any one done this? Or does Formulate have any helpers I can use?
Cheers, Jay
This may help: https://our.umbraco.com/packages/backoffice-extensions/formulate/formulate-questions/81853-formulate-and-web-forms
In particular this commit: https://github.com/Nicholas-Westby/web-formulate/commit/4125a398d48cf7589ec28b99d62ef157ccfd80c7
It's been a while, but it looks like I got Formulate working with a macro (in this case, on a WebForms project, but should translate well to Razor). I suppose this is the most relevant bit of code you'll want to focus on:
Let me know if you have questions.
Thanks for the reply Nicholas.
This doesnt seem to work at I get a null exception reference when trying to get: var content = context.PublishedContentRequest.PublishedContent;
I suggest digging in a bit more. I bet there is a way to do it, though I don't have the method off the top of my head.
All that line is really doing is getting the current page.
I just can't get the ConfiguredFormInfo Model at all. All I get back from the Macro Parameter is the Id of the Form nothing else. And then I cant seem to get the form using the ID what so ever. I might have to change the way I am using the Form Picker and move it away from the Macro and just put it onto the Document Type itself and just use the Macro to display the form.
Im using App Data models this wouldnt affect it would it?
I personally don't use Umbraco macros and wouldn't recommend them, unless you're using Umbraco Grid (which are a different type of macro).
I tend to build widget-based websites, so I have a "form" widget with a Formulate form picker property: https://skrift.io/articles/archive/building-umbraco-websites-with-archetype-widgets-and-ditto/
But putting the form picker property on the doctype itself would be a fine approach too.
Not sure what you mean by "App Data models". Are you using Models Builder and the C# classes for the models are placed in the
App_Data
folder? If so, I imagine that'd be fine, but I haven't tried combining models builder and Formulate before. Worth a shot.is working on a reply...