How to reference to a Sitefinity Form in a Custom Field

498 Views Asked by At

I am working on a custom sitefinity module in which I need to add a custom field where I can select a Sitefinity Form from a list of existing defined forms on the backend. What is the best approach to do this? Precisely how should I approach in defining the field and making its UI?

Unfortunately when I select "Related Data" as field type, Sitefinity Form is not available in the list of built-in data types. The other option (advanced option) I see is a GUID (or array of GUIDs) field type among field types which suggest making a custom code.

CMS version is Sitefinity 8.2 and we are using MVC-based feather components as well as our custom MVC components to develop the website.

Anybody had similar requirement and experience on this?

1

There are 1 best solutions below

0
On

I would probably create a custom field control. This can be streamlined by using Sitefinity Thunder (because there's a lot of boilerplate C# and JavaScript needed). Once that's in place, you can create a custom field of either type Short Text or GUID, and for the interface, you use your custom field.

In your custom field's code, you can do something like creating a drop down list, where the text for each option is the form name, and the value is either the "name for developers" field or the ID of the form. That way the input is always constrained to IDs pointing to Sitefinity forms. Then when you interact with your custom content items later, you can use this ID/name to look up the referenced form.

As an aside about Related Data: Indeed, that only refers to either built-in content types (blogs, news, etc.) or custom-build dynamic content types. You won't find things like Forms in there.