| 1 |
Drupal wforms.module README.txt
|
| 2 |
==============================================================================
|
| 3 |
|
| 4 |
Created by CivicSpace Labs as part of a project for GoodStorm, this module
|
| 5 |
provides methods for client-side interactive forms using the wForms library
|
| 6 |
by Cédric Savarese (http://www.4213miles.com). See wForms documentation at
|
| 7 |
|
| 8 |
http://www.formassembly.com/wForms/
|
| 9 |
|
| 10 |
|
| 11 |
Requirements
|
| 12 |
------------------------------------------------------------------------------
|
| 13 |
This module is written for Drupal 4.7.
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
Installation
|
| 18 |
------------------------------------------------------------------------------
|
| 19 |
Create a directory modules/wforms (or, for easy updating,
|
| 20 |
modules/jstools/wforms) and copy all the module's files into it.
|
| 21 |
|
| 22 |
The wForms library must be downloaded separately from
|
| 23 |
|
| 24 |
http://www.formassembly.com/wForms/
|
| 25 |
|
| 26 |
See the download link for the wForms v2.0 "packed version".
|
| 27 |
|
| 28 |
Copy the following three files from the download to your /wforms
|
| 29 |
module directory:
|
| 30 |
|
| 31 |
wforms.css
|
| 32 |
wforms.js
|
| 33 |
wforms-jsonly.css
|
| 34 |
|
| 35 |
Enable the module via the administer > modules page.
|
| 36 |
|
| 37 |
|
| 38 |
Developer usage
|
| 39 |
------------------------------------------------------------------------------
|
| 40 |
|
| 41 |
Multi-page forms
|
| 42 |
----------------------
|
| 43 |
|
| 44 |
Each page of the form is an element of type 'wformspage'. This
|
| 45 |
element type is basically a wrapper that encloses form sections in
|
| 46 |
a div with the appropriate class names to trigger the wForms multi-
|
| 47 |
page behavior.
|
| 48 |
|
| 49 |
Construct a multi-page form as follows:
|
| 50 |
|
| 51 |
// First page
|
| 52 |
$form['page1'] = array(
|
| 53 |
'#type' => 'wformspage',
|
| 54 |
'#title' => t('Page 1')
|
| 55 |
);
|
| 56 |
$form['page1']['title'] = array(
|
| 57 |
'#type' => 'textfield',
|
| 58 |
'#title' => t('Title'),
|
| 59 |
'#description' => t('Give a title to your item'),
|
| 60 |
'#required' => TRUE,
|
| 61 |
'#size' => 30
|
| 62 |
);
|
| 63 |
|
| 64 |
// Second page
|
| 65 |
$form['page2'] = array(
|
| 66 |
'#type' => 'wformspage',
|
| 67 |
'#title' => t('Page 2')
|
| 68 |
);
|
| 69 |
$form['page2']['body'] = array(
|
| 70 |
'#type' => 'textarea',
|
| 71 |
'#title' => t('Description'),
|
| 72 |
'#description' => t('Describe your item'),
|
| 73 |
'#rows' => 3,
|
| 74 |
'#cols' => 30,
|
| 75 |
'#required' => TRUE
|
| 76 |
);
|
| 77 |
|
| 78 |
Validation
|
| 79 |
----------------------
|
| 80 |
|
| 81 |
Validation for required fields works out of the box, as wForms recognizes
|
| 82 |
Drupal 'required' class names.
|
| 83 |
|
| 84 |
For other types of validation, add classes that trigger validation
|
| 85 |
behaviors--see the list of supported selectors at:
|
| 86 |
|
| 87 |
http://www.formassembly.com/blog/input-validation-explained/
|
| 88 |
|
| 89 |
Example:
|
| 90 |
|
| 91 |
$form['page1']['email'] = array(
|
| 92 |
'#type' => 'textfield',
|
| 93 |
'#title' => t('Email'),
|
| 94 |
'#size' => 30,
|
| 95 |
'#attributes' => array('class' => 'validate-email')
|
| 96 |
);
|
| 97 |
|
| 98 |
Further functionality
|
| 99 |
----------------------
|
| 100 |
|
| 101 |
Other behaviors can be added through adding classes and enclosing divs
|
| 102 |
to form elements (e.g., using form elements' '#prefix' and '#suffix' selectors).
|
| 103 |
|
| 104 |
See the wForms documentation, http://www.formassembly.com/wForms/
|