Tags:
create new tag
view all tags
At times we might want to enforce data entry to web forms. For example, we might want to insist that users enter a ProjectGroup in the WebForm attached to this topic (just an example).

I have attached a patch that allows an additional optional field to be added to the form definition, see excerpt from TWikiForms:

  • An optional additional column "Mandatory" may be entered at the end of the definition of a WebForm.
    • If a row has a non-empty content (strictly speaking, not equivalent to Boolean false) in this cell, the form specified by this WebForm cannot be saved if the corresponding field does not have a value specified.
    • Otherwise, i.e., if the cell is empty or absent, no validation is performed when attempting to save a topic containing such a form.

Example: Modified WebForm from the TWiki.Know web
| *Name* | *Type* | *Size* | *Values* | *Tooltip message* | *Mandatory* |
| Know.TopicClassification | select | 1 | Know.NoDisclosure, 
  Know.PublicSupported, Know.PublicFAQ | blah blah... | |
| Know.OperatingSystem | checkbox | 3 | Know.OsHPUX, Know.OsLinux,
  Know.OsSolaris, Know.OsWin | blah blah... | |
| Know.OsVersion | text | 16 | | blah blah... | Yes |
Name Type Size Values Tooltip message Mandatory
TopicClassification select 1 NoDisclosure, PublicSupported, PublicFAQ blah blah...  
OperatingSystem checkbox 3 OsHPUX, OsLinux, OsSolaris, OsWin blah blah...  
OsVersion text 16   blah blah... Yes

A topic containing this WebForm can only be saved if the OsVersion field is filled in.

When a topic containing this form is being edited, mandatory fields are marked with a red asterisk and a legend appears at the bottom (only if mandatory fields are present). If a user does not enter data for such a mandatory field, upon entering preview an oops is raised and saving is prevented. The user is asked to return to continue editing the topic.

Warning: The attached patch is against the Athens release. I need to still port it to the Beijing release.

-- ThomasWeigert - 13 Apr 2003

I've already extended forms to have an option field. This could certainly be used to make some field as manditory. Additionally a plugin hook could be added so that more general validation could be done by a plugin. The only use of the option field at present is to make an entry as a setting.

-- JohnTalintyre - 13 Apr 2003

Thanks for pointing this out. I'll check into how you are using the "option field", when I convert this to work with the Beijing release. Note that the main work in the attached patch is in enforcing that mandatory fields are filled in.

A more general validation would be useful, albeit I cannot see how that could be independent of the application, so we would end up having to write perl code at the user level (except for very simple type checking of entered data).

-- ThomasWeigert - 14 Apr 2003

See UsingFormsForSettings for the new field. Note that this is part of the CairoRelease. One thing you could validate is a date, I'm sure there are other generic things, plus as you say, the ability to do things at a Perl level e.g. deal with changes in workflow, which could affect what is manditory.

-- JohnTalintyre - 14 Apr 2003

Topic attachments
I Attachment History Action Size Date Who Comment
Compressed Zip archivezip FormValidation.zip r1 manage 3.2 K 2003-04-13 - 18:53 UnknownUser Patch for Athens release
Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2003-04-14 - JohnTalintyre
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.