/[drupal]/contributions/modules/validation_api/README.txt
ViewVC logotype

Contents of /contributions/modules/validation_api/README.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Wed Jul 2 23:02:43 2008 UTC (16 months, 3 weeks ago) by tapocol
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-ALPHA1, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.2: +16 -3 lines
File MIME type: text/plain
Change to the structure. Making validations on the whole form, if the form has a field associated with it.
1 $Id: README.txt,v 1.2 2008/06/30 21:58:04 tapocol Exp $
2 Validation API Module
3 Author: Craig Jackson <tapocol [at] gmail [dot] com>
4 This module is apart of the 2008 Google Summer of Code.
5 Validation API allows to be able to add validation rules to any field on your site. However, the latest versions are limited to text-based core fields.
6 Currently, the JavaScript portion is not tied in, and it will be getting switched over to jQuery.
7
8 How to Use:
9 1.) Install like any other Drupal module.
10 Place validation_api in your modules folder (recommend: /sites/all/modules/).
11 Goto admin/build/modules, check enabled on Validation API, and click submit.
12 2.) Creating validators.
13 There are three options:
14 Admin Form (admin/build/validation_api/validators/add)
15 Importing validators (admin/build/validation_api/validators/import)
16 Through 'add_validators' hook to upload the validators from the hook, goto the import page
17 (see 'validation_api_add_validators' function for more info on the hook)
18 You can create php or regex types.
19 The rule for php types uses $value for the value entered and $arg, if there is an argument needed for each field.
20 The rule for regex types uses %arg, if there is an argument needed for each field.
21 3.) After adding validators, then create relationships with the validator and fields.
22 Add field (admin/build/validation_api/fields/add).
23 If you do not know the form id and/or field name of the field you want to validate,
24 you can goto the form on the site, and click the 'Add validator to this field' link.
25 **** WARNING: There is problems with CCK fields and types that are not text-oriented fields.
26 Check out the Validator + Field Example below to see what the argument field is used for.
27 4.) You should be able to go to that form and validate with your new condition.
28
29 Validator Example:
30 Fill out the form at admin/build/validation_api/validators/add
31 Name: email
32 Type: php
33 Rule: return valid_email_address($value);
34 Message: %field needs to be a valid email address.
35
36 Validator + Field Example:
37 Make sure you have a node created
38 Import the hook that comes with this module (length) at the import page.
39 Then, goto the fields section, and add this:
40 Form ID: comment_form
41 Field Name: comment
42 Validator: length
43 Argument: 10
44
45 This will validate comment_form's comment field on submit, and make sure it is at least 10 characters.
46 Go test it to make sure, try to add a comment to a node. You can use preview to test so you don't submit comments.

  ViewVC Help
Powered by ViewVC 1.1.2