Difference between revisions of "Template:FormDateField"

From Encyclopedia of Scientonomy
Jump to navigation Jump to search
(Replaced content with "{{{field|abstract|input type=textarea|rows=15|cols=90}}} {{{field|just some text|input type=dropdown|values=BCE,CE}}}")
Tag: Replaced
Line 1: Line 1:
{{{field|abstract|input type=textarea|rows=15|cols=90}}}
+
<noinclude>
{{{field|just some text|input type=dropdown|values=BCE,CE}}}
+
This template is called from within Semantic Forms to display a Date field.
 +
 
 +
'''NOTE:''' This is a "form" template; it should NOT be called from anywhere except a semantic form.
 +
 
 +
It creates the following entry fields:
 +
* <code><nowiki>{{{property|}}} Era</nowiki></code> - CE or BCE; the default is CE.
 +
* <code><nowiki>{{{property|}}} Year</nowiki></code> - the year field; accepts 4 integers.
 +
* <code><nowiki>{{{property|}}} Month</nowiki></code> - the month field.
 +
* <code><nowiki>{{{property|}}} Day</nowiki></code> - the day field.
 +
* <code><nowiki>{{{property|}}} Approximate</nowiki></code> - if day field.
 +
 +
'''Parameters:'''
 +
* <code><nowiki>|property=</nowiki></code> - the name of the property; must be unique for the form. The template will use this value to create several fields ending with Year, Month, Day, etc.
 +
* <code><nowiki>|mandatory=</nowiki></code> - if yes, then the combined field return some value. The default is no.
 +
* <code><nowiki>|dataprecision=</nowiki></code> - Year, Month, or Day. Depending on this parameter, the respective fields will be made mandatory. The default is Day.
 +
* <code><nowiki>|showera=</nowiki></code> - if yes, then the era will be show; if no (default), then the era field will not be shown and the value of CE will be set automatically.
 +
* <code><nowiki>|showapproximate=</nowiki></code> - if yes, the approximate field will be shown; if no (default), then the approximate field will not be shown and the date will be considered not approximate (i.e. precise).
 +
* <code><nowiki>|showmonthdayfields=</nowiki></code> - if yes (default), the Month and Day fields will be shown even if dataprecision=Year. If no, the Month and Day fields will only be shown if necessary.
 +
* <code><nowiki>|showcaptions=</nowiki></code> - if yes (default), the captions (''Year'', ''Month'' etc.) will be shown.
 +
* <code><nowiki>|adddefualt=</nowiki></code> - if yes, the date fields will have the value of ''now'' by default. If no (default), no default will be added to the fields.
 +
 
 +
</noinclude><includeonly><!--
 +
--><!--
 +
--><!-- calculate mandatory values
 +
-->{{#ifeq: {{{mandatory|}}}|yes<!--
 +
--><!-- year field: mandatory
 +
-->|{{#vardefine: varMandatoryYear|&#124;mandatory}}<!--
 +
--><!-- for month and day fields the mandatory values will depend on the dataprecision parameter
 +
  -->{{#switch: {{{dataprecision|Day}}} <!--
 +
  -->|Day|Month={{#vardefine: varMandatoryMonth|&#124;mandatory}}<!--
 +
  -->|#default={{#vardefine: varMandatoryMonth|}}<!--
 +
  -->}}<!-- switch
 +
  -->{{#switch: {{{dataprecision|Day}}} <!--
 +
  -->|Day={{#vardefine: varMandatoryDay|&#124;mandatory}}<!--
 +
  -->|#default={{#vardefine: varMandatoryDay|}}<!--
 +
  -->}}<!-- switch
 +
--><!-- else: nothing is mandatory
 +
-->|{{#vardefine: varMandatoryYear|}}<!--
 +
  -->{{#vardefine: varMandatoryMonth|}}<!--
 +
  -->{{#vardefine: varMandatoryDay|}}<!--
 +
-->}}<!--
 +
--><!-- 
 +
--><!-- calculate visibility for month and day fields 
 +
-->{{#ifeq:{{{showmonthdayfields|}}}|yes<!--
 +
--><!-- showmonthdayfields=yes: always visible 
 +
-->|{{#vardefine: varMonthVisible|yes}}<!--
 +
  -->{{#vardefine: varDayVisible|yes}}<!--
 +
--><!-- else: depends on the dataprecision parameter
 +
-->|{{#switch: {{{dataprecision|Day}}} <!--
 +
  -->|Day|Month={{#vardefine: varMonthVisible|yes}}<!--
 +
  -->|#default={{#vardefine: varMonthVisible|no}}<!--
 +
  -->}}<!-- switch
 +
  -->{{#switch: {{{dataprecision|Day}}} <!--
 +
  -->|Day={{#vardefine: varDayVisible|yes}}<!--
 +
  -->|#default={{#vardefine: varDayVisible|no}}<!--
 +
  -->}}<!-- switch
 +
-->}}<!-- 
 +
--><!-- 
 +
--><!-- start displaying
 +
--><!-- show era if necessary
 +
-->
 +
{{{field&#124;abstract|input type=textarea&#124;rows=15&#124;cols=90}}}
 +
{{{field&#124;just some text&#124;input type=dropdown&#124;values=BCE,CE}}}
 +
 
 +
{{#if: {{#var: varMandatoryYear}}<!--
 +
-->|{{#vardefine: varRegexp|/^\d{4}$/}}<!-- 4 digits only
 +
-->|{{#vardefine: varRegexp|/^\d{4}$!^$/}}<!-- allow blanks
 +
-->}}<!--
 +
--><!--
 +
-->&#32;{{#ifeq: {{{showcaptions|yes}}}|yes|''Year:''&#32;|}}{{{field&#124;{{{property|}}} Year&#124;input type=regexp&#124;regexp={{#var:varRegexp}}&#124;size=4&#124;message=The year field can accept only integers and must be 4 digits in length!{{#ifeq:{{{adddefault|}}}|yes|&#124;default={{CURRENTYEAR}}|}}{{#var:varMandatoryYear}}}}}<!--
 +
--><!--
 +
--><!--
 +
--><!-- if dataprecision is month or day - add the month field
 +
-->{{#switch: {{{dataprecision|Day}}} <!--
 +
-->|Month|Day=<!--
 +
-->}}<!-- switch
 +
--><!--
 +
-->{{#ifeq: {{#var:varMonthVisible}}|yes|<!--
 +
-->&#32;{{#ifeq: {{{showcaptions|yes}}}|yes|''Month:''&#32;|}}{{{field&#124;{{{property|}}} Month&#124;input type=dropdown&#124;values=January,February,March,April,May,June,July,August,September,October,November,December{{#ifeq:{{{adddefault|}}}|yes|&#124;default={{CURRENTMONTHNAME}}|}}{{#var:varMandatoryMonth}} }}}<!--
 +
--><!--
 +
-->{{#ifeq: {{#var:varDayVisible}}|yes|<!--
 +
  -->&#32;{{#ifeq: {{{showcaptions|yes}}}|yes|''Day:''&#32;|}}{{{field&#124;{{{property|}}} Day&#124;input type=dropdown&#124;values=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31{{#ifeq:{{{adddefault|}}}|yes|&#124;default={{CURRENTDAY}}|}}{{#var:varMandatoryDay}}}}}<!--
 +
-->}}<!-- ifeq day
 +
--><!--
 +
-->}}<!-- ifeq month
 +
--><!--
 +
-->{{#ifeq: {{{showapproximate|}}}|yes|&#32;{{#ifeq: {{{showcaptions|yes}}}|yes|''Approximate?''&#32;|}}{{{field&#124;{{{property|}}} Approximate&#124;input type=checkbox}}}|}}<!-- show approximate if necessary
 +
--><!--
 +
--><!--
 +
--><!--
 +
-->
 +
</includeonly>

Revision as of 21:51, 1 June 2020

This template is called from within Semantic Forms to display a Date field.

NOTE: This is a "form" template; it should NOT be called from anywhere except a semantic form.

It creates the following entry fields:

  • {{{property|}}} Era - CE or BCE; the default is CE.
  • {{{property|}}} Year - the year field; accepts 4 integers.
  • {{{property|}}} Month - the month field.
  • {{{property|}}} Day - the day field.
  • {{{property|}}} Approximate - if day field.

Parameters:

  • |property= - the name of the property; must be unique for the form. The template will use this value to create several fields ending with Year, Month, Day, etc.
  • |mandatory= - if yes, then the combined field return some value. The default is no.
  • |dataprecision= - Year, Month, or Day. Depending on this parameter, the respective fields will be made mandatory. The default is Day.
  • |showera= - if yes, then the era will be show; if no (default), then the era field will not be shown and the value of CE will be set automatically.
  • |showapproximate= - if yes, the approximate field will be shown; if no (default), then the approximate field will not be shown and the date will be considered not approximate (i.e. precise).
  • |showmonthdayfields= - if yes (default), the Month and Day fields will be shown even if dataprecision=Year. If no, the Month and Day fields will only be shown if necessary.
  • |showcaptions= - if yes (default), the captions (Year, Month etc.) will be shown.
  • |adddefualt= - if yes, the date fields will have the value of now by default. If no (default), no default will be added to the fields.