Template:CheckFields

From Pestinfo-Wiki
Jump to: navigation, search

This template was used for and old version of Form:NewArticle7, but is now obsolete.

The template takes the following 4 parameters:

  1. Error message
  2. field 1
  3. field 2
  4. field 3

At least 2 of the 3 fields must be completed, otherwise an error message is returned. If the Error message (first parameter) already contains some text then the separator ";;" and the new message is appended. If there is no error parameter 1 is returned.

The template has the following structure:

1. Define the Error variable
{{#vardefine:Error|
   {{#if:{{{1}}}|{{{1}}};;}}
   '''<font color='red'>Error: Two of the 3 important fields need to be completed (see
   description on the form below), at least one of these 3 fields has not been
   completed</font>. Please redo the entry.'''
}}
2. Do at least 2 of the 3 fields exist?
   Yes - return any previous error messages, No - return the new error message 
{{#if:{{{2}}}|
   {{#if:{{{3}}}|
      {{{1}}}
   | (ELSE)
      {{#if:{{{4}}}|
         {{{1}}}
      | (ELSE)
         {{#var:Error}}
      }}
   }}
| (ELSE)
   {{#if:{{{3}}}|
      {{#if:{{{4}}}|
         {{{1}}}
      | (ELSE)
         {{#var:Error}}
      }}
   | (ELSE)
      {{#var:Error}}
   }}
}}