Difference between revisions of "Template:FormDateField"

From Encyclopedia of Scientonomy
Jump to navigation Jump to search
Line 1: Line 1:
<noinclude>
+
{{#ifeq:{{{showera|}}}|yes|{{#ifeq: {{{showcaptions|yes}}}|yes|''Era:''&#32;|}}{{{field#124;{{{property|}}} Era&#124;input type=dropdown&#124;values=BCE,CE{{#ifeq:{{{adddefault|}}}|yes|&#124;default=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
 
-->{{#ifeq:{{{showera|}}}|yes|{{#ifeq: {{{showcaptions|yes}}}|yes|''Era:''&#32;|}}{{{field#124;{{{property|}}} Era&#124;input type=dropdown&#124;values=BCE,CE{{#ifeq:{{{adddefault|}}}|yes|&#124;default=CE|}}}}}|}}
 
  
 
{{#if: {{#var: varMandatoryYear}}<!--  
 
{{#if: {{#var: varMandatoryYear}}<!--  

Revision as of 21:03, 1 June 2020


Year: {{{field| Year|input type=regexp|regexp=/^\d{4}$!^$/|size=4|message=The year field can accept only integers and must be 4 digits in length!}}}</includeonly>