Chapter 12. Forms

Table of Contents

Intro
Creating a form

Intro

Forms are essential for any dynamic site. Tangra framework provides vary rich form functionality that makes easy to define forms, automatically generate HTML for them, validate submitted input, AJAX usage, etc. This chapter will present basics about how to work with forms and later in Chapter 15, Forms: Advanced Usage we will discuss more complicated topics.

Main components are:

  • class Form and descendant classes. Represents HTML form.
  • class Form_Field and descendant classes - TF provides ready-to-use classes for common types like text, integer, date, email, etc. Additionally you can easily create your own types to reflect your needs. Each Form_Field_* class contains mechanism for validating submitted input.
  • class Form_View and descendant classes. Represents form view.
  • class Form_Field and descendant classes. Represent form field views.
  • HTML templates for forms and form fields - used to generate automatically HTML for your forms. Such templates are provided as modules (form_html_tpl_static_ajax_metallic* for example). Third party developers can create their own modules to provide different look and feel.
  • GForm and GFO WPs - provides base classes for WPs with forms
  • Ajax_Form_Ctrl - provides AJAX support for forms.

At first creating a form may look kind of complicated but when you get used to it you will be able to create simple form in about 5 minutes. In future versions of Tangra Framework (more precise in TCC) we will add wizard for creating forms where you can chose in GUI what fields to include (or may be even easier - choose DB table and TCC will generate the form for it).