Custom question types
You can define your own custom question types for forms. These question types can be found in the "Custom" tab in the form application when adding questions. Naturally, this tab only appears if there's at least one custom question type available.
As an example, we're creating a (disabled) textedit field that will generate a unique code.
Select a namespace, for example 'http://www.mysite.net/xmlns/forms'. In the module's moduledefinition.xml file (assuming the module is called 'mymodule'), create a form definition file, mymodule/data/formdef.xsd, and fill it with:
Refer to this form definition in your moduledefinition.xml by adding the following tags (if you have an existing <publisher> section, just add the <formcomponents> there):
Let's define the screen first. We're creating a field that generates a code, but we also want this code to be based on a certain 'tag' that can be chosen by the content manager.
Create a mymodule/formcomponents/formcomponents.xml file containing the following:
Now it's time to add some logic, by creating a mymodule/formcomponents/formcomponents.whlib file:
To enable the custom fields, tell your site profile about it. This can be done by adding this piece of code to your main site profile: