AJAX Form Messages, an API to provide an enhanced user interface for forms– catching errors before the submit button is hit

Events happening in the community are now at Drupal community events on www.drupal.org.
mlncn's picture

This module will provide an API and a UI for immediate inline validation or other checking and responding of form elements. (Contrast this with AJAX module, which validates the entire form via AJAX when the submit or preview button is pressed.)

The ideal will be to automate using (or make it very simple to use) existing form element validation functions as the back-end of inline validators.

The initial motivation was to extend (and make an honest module out of) Unique Fields AJAX checking, but the number of nice-to-haves and ought-to-bes make point the way to a new API for setting message conditions and messages. This will be developed API-first.

Notes from my due diligence are here: http://data.agaric.com/raw/ajax-form-messages-proposed-module

While the API will allow for custom messages based on any sort of check, the main use case AJAX Form Messages is being developed for is to warn users when entering duplicate data (uniqueness conflicts). Sean (undoIT) describes:

There would need to be the ability to optionally enable form messages based on the uniqueness of a combination of two or more fields (in the same way that Unique Field provides the option "The combination of values from the specified fields must be unique").

For example, a node exists with the vocabulary: color and taxonomy terms: "Red", "Green" etc. and there is CCK text field for fruit. The CCK field for fruit and vocabulary are checked off as "The combination of values from the specified fields must be unique".

A node already exists for term: Red and fruit: "apple"

A user is adding a new node and selects the term "Red". If that user then tries to add "apple" to the color CCK field, it would give the error message.

However, if the user were to select the term: "Green" and fruit: "apple", or term:"Red" and fruit: "strawberry" no error would be displayed since no nodes have been added yet with those term / CCK combinations.

under: /admin/content/node-type/page or whatever the node-type is...

1. A collapsible fieldset for "AJAX Form Messages".
2. When fieldset is expanded, a button "Add Uniqueness Messages".
3. After clicking button, a drop-down select-list with all relevant CCK Fields and Node Title labeled "Field to check".
4. Below "Field to check" would be two text fields for "TRUE" and "FALSE" for custom messages (TRUE=value is unique, FALSE=value not unique)
5. Below custom messages would be check-boxes in a fieldset (or grouping div) "Unique in combination with". The check-boxes would list all relevant CCK fields, along with Node Title, and selectors for Terms from any Vocabularies assigned to the node-type. "Unique in combination with" would be optional.
6. After entry has been saved, it would be listed in a "Uniqueness Messages" table or list with existing entries (i.e. CCK field chosen as "Field to check" and a link to edit).
7. More uniqueness messages could be added by clicking the "Add Uniqueness Messages" button.

Comments

The project for this idea is posted

mlncn's picture

http://drupal.org/project/formmsgs

... if you wish to add feature requests there (commenting here is great too!), or throw it directly into the duplicate module hall of shame.

benjamin, agaric

varun.sureka's picture

Hello Sir,

As i am a new in drupal specifically module development. Can you please guide me how to create a simple form module which takes input and submit the data in the database. Or any web site that has clear steps for doing these kind of things then please do help me. I will be highly obliged.

Some good starting points

arpieb's picture

There are several good resources on drupal.org regarding building forms, this being the best starting place:

Form API Reference

Also, if you simply need to collect data and don't require custom DB table(s), you might look into the excellent Webform module.

Form API

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week