Version 4 > Developer's Guide > Plugins and Frameworks > Forms

Forms

The v3 QA framework is replaced by v4's Forms framework. Forms and questions are now content objects, which means:

  • they use standard access controls and translation tools
  • the revisions are treated as templates. Revisions of a form are the layout/template for the form, while revisions of a question are used as a layout/template for that one question.

New features that are made possible by this approach:

  • layouts are contained in the form, not in libraries
  • no question libraries; just re-use questions by copying them from old forms
  • smarter question layouts (eg. checkboxes first)

Other new features that have also been added:

  • HTML input types
  • drag-and-drop question ordering
  • context-sensitive question setup and configuration

Note that, as content objects, forms do not utilize service pages any more. However, forms effectively serve as their own service page. To embed a form into a page, place the form content object under that page, and embed it into the page content using < !--content(form_name)-->. Submitting that form effectively directs you to /cgi/ex.cgi/page_name/form_name, which allows you to customize the layout of the form response.

As a developer, the primary change to consider is that forms are not remote objects that are referenced through a qa_form_id, but are content objects that can be embedded right in the object you are working on. For example a registration fee can contain its own form as sub-content. Or a membership type can contain a sign-up form as sub-content. To check for the existence of such a form, do this:

$registration_form = $fee->my_content("registration_form");

$registration_form will now be the form object itself, if one exists.