/wheels/view/formsdateplain.cfm

http://cfwheels.googlecode.com/ · ColdFusion · 333 lines · 322 code · 11 blank · 0 comment · 127 complexity · 7b90d48cc46b5921c4968e3c2e0c2143 MD5 · raw file

  1. <cffunction name="dateSelectTags" returntype="string" access="public" output="false" hint="Builds and returns a string containing three select form controls (month, day, and year) based on a `name` and `value`."
  2. examples=
  3. '
  4. <!--- This "Tag" version of function accepts `name` and `selected` instead of binding to a model object --->
  5. <cfoutput>
  6. ##dateSelectTags(name="dateStart", selected=params.dateStart)##
  7. </cfoutput>
  8. <!--- Show fields for month and year only --->
  9. <cfoutput>
  10. ##dateSelectTags(name="expiration", selected=params.expiration, order="month,year")##
  11. </cfoutput>
  12. '
  13. categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,textFieldTag,submitTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,timeSelectTags">
  14. <cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
  15. <cfargument name="selected" type="string" required="false" default="" hint="See documentation for @selectTag.">
  16. <cfargument name="order" type="string" required="false" hint="See documentation for @dateSelect.">
  17. <cfargument name="separator" type="string" required="false" hint="See documentation for @dateSelect.">
  18. <cfargument name="startYear" type="numeric" required="false" hint="See documentation for @dateSelect.">
  19. <cfargument name="endYear" type="numeric" required="false" hint="See documentation for @dateSelect.">
  20. <cfargument name="monthDisplay" type="string" required="false" hint="See documentation for @dateSelect.">
  21. <cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
  22. <cfargument name="label" type="string" required="false" hint="See documentation for @dateSelect.">
  23. <cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
  24. <cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
  25. <cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
  26. <cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
  27. <cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
  28. <cfargument name="combine" type="boolean" required="false" hint="See documentation for @dateSelect.">
  29. <cfscript>
  30. $args(name="dateSelectTags", args=arguments);
  31. arguments.property = arguments.name;
  32. arguments.objectName = {};
  33. arguments.objectName[arguments.name] = arguments.selected;
  34. StructDelete(arguments, "name");
  35. StructDelete(arguments, "selected");
  36. arguments.$functionName = "dateSelectTag";
  37. </cfscript>
  38. <cfreturn $dateOrTimeSelect(argumentCollection=arguments)>
  39. </cffunction>
  40. <cffunction name="timeSelectTags" returntype="string" access="public" output="false" hint="Builds and returns a string containing three select form controls for hour, minute, and second based on `name`."
  41. examples=
  42. '
  43. <!--- This "Tag" version of function accepts `name` and `selected` instead of binding to a model object --->
  44. <cfoutput>
  45. ##timeSelectTags(name="timeOfMeeting" selected=params.timeOfMeeting)##
  46. </cfoutput>
  47. <!--- Show fields for `hour` and `minute` only --->
  48. <cfoutput>
  49. ##timeSelectTags(name="timeOfMeeting", selected=params.timeOfMeeting, order="hour,minute")##
  50. </cfoutput>
  51. '
  52. categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags">
  53. <cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
  54. <cfargument name="selected" type="string" required="false" default="" hint="See documentation for @selectTag.">
  55. <cfargument name="order" type="string" required="false" hint="See documentation for @timeSelect.">
  56. <cfargument name="separator" type="string" required="false" hint="See documentation for @timeSelect.">
  57. <cfargument name="minuteStep" type="numeric" required="false" hint="See documentation for @timeSelect.">
  58. <cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
  59. <cfargument name="label" type="string" required="false" hint="See documentation for @dateSelect.">
  60. <cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
  61. <cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
  62. <cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
  63. <cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
  64. <cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
  65. <cfargument name="combine" type="boolean" required="false" hint="See documentation for @dateSelect.">
  66. <cfargument name="twelveHour" type="boolean" required="false" default="false" hint="See documentation for @timeSelect.">
  67. <cfscript>
  68. $args(name="timeSelectTags", args=arguments);
  69. arguments.property = arguments.name;
  70. arguments.objectName = {};
  71. arguments.objectName[arguments.name] = arguments.selected;
  72. StructDelete(arguments, "name");
  73. StructDelete(arguments, "selected");
  74. arguments.$functionName = "timeSelectTag";
  75. </cfscript>
  76. <cfreturn $dateOrTimeSelect(argumentCollection=arguments)>
  77. </cffunction>
  78. <cffunction name="dateTimeSelectTags" returntype="string" access="public" output="false" hint="Builds and returns a string containing six select form controls (three for date selection and the remaining three for time selection) based on a `name`."
  79. examples=
  80. '
  81. <!--- This "Tag" version of the function accepts a `name` and `selected` instead of binding to a model object --->
  82. <cfoutput>
  83. ##dateTimeSelectTags(name="dateTimeStart", selected=params.dateTimeStart)##
  84. </cfoutput>
  85. <!--- Show fields for month, day, hour, and minute --->
  86. <cfoutput>
  87. ##dateTimeSelectTags(name="dateTimeStart", selected=params.dateTimeStart, dateOrder="month,day", timeOrder="hour,minute")##
  88. </cfoutput>
  89. '
  90. categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateSelectTags,timeSelectTags">
  91. <cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
  92. <cfargument name="selected" type="string" required="false" default="" hint="See documentation for @selectTag.">
  93. <cfargument name="dateOrder" type="string" required="false" hint="See documentation for @dateTimeSelect.">
  94. <cfargument name="dateSeparator" type="string" required="false" hint="See documentation for @dateTimeSelect.">
  95. <cfargument name="startYear" type="numeric" required="false" hint="See documentation for @dateSelect.">
  96. <cfargument name="endYear" type="numeric" required="false" hint="See documentation for @dateSelect.">
  97. <cfargument name="monthDisplay" type="string" required="false" hint="See documentation for @dateSelect.">
  98. <cfargument name="timeOrder" type="string" required="false" hint="See documentation for @dateTimeSelect.">
  99. <cfargument name="timeSeparator" type="string" required="false" hint="See documentation for @dateTimeSelect.">
  100. <cfargument name="minuteStep" type="numeric" required="false" hint="See documentation for @timeSelect.">
  101. <cfargument name="separator" type="string" required="false" hint="See documentation for @dateTimeSelect.">
  102. <cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
  103. <cfargument name="label" type="string" required="false" hint="See documentation for @dateSelect.">
  104. <cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
  105. <cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
  106. <cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
  107. <cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
  108. <cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
  109. <cfargument name="combine" type="boolean" required="false" hint="See documentation for @dateSelect.">
  110. <cfargument name="twelveHour" type="boolean" required="false" default="false" hint="See documentation for @timeSelect.">
  111. <cfscript>
  112. var loc = {};
  113. $args(name="dateTimeSelectTags", args=arguments);
  114. loc.returnValue = "";
  115. loc.separator = arguments.separator;
  116. loc.label = arguments.label;
  117. // create date portion
  118. arguments.order = arguments.dateOrder;
  119. arguments.separator = arguments.dateSeparator;
  120. // when a list of 6 elements has been passed in as labels we assume the first 3 are meant to be placed on the date related tags
  121. if (ListLen(loc.label) == 6)
  122. arguments.label = ListGetAt(loc.label, 1) & "," & ListGetAt(loc.label, 2) & "," & ListGetAt(loc.label, 3);
  123. if (StructKeyExists(arguments, "$functionName") && arguments.$functionName == "dateTimeSelect")
  124. loc.returnValue = loc.returnValue & dateSelect(argumentCollection=arguments);
  125. else
  126. loc.returnValue = loc.returnValue & dateSelectTags(argumentCollection=arguments);
  127. // separate date and time with a string ("-" by default)
  128. loc.returnValue = loc.returnValue & loc.separator;
  129. // create time portion
  130. arguments.order = arguments.timeOrder;
  131. arguments.separator = arguments.timeSeparator;
  132. // when a list of 6 elements has been passed in as labels we assume the last 3 are meant to be placed on the time related tags
  133. if (ListLen(loc.label) == 6)
  134. arguments.label = ListGetAt(loc.label, 4) & "," & ListGetAt(loc.label, 5) & "," & ListGetAt(loc.label, 6);
  135. if (StructKeyExists(arguments, "$functionName") && arguments.$functionName == "dateTimeSelect")
  136. loc.returnValue = loc.returnValue & timeSelect(argumentCollection=arguments);
  137. else
  138. loc.returnValue = loc.returnValue & timeSelectTags(argumentCollection=arguments);
  139. </cfscript>
  140. <cfreturn loc.returnValue>
  141. </cffunction>
  142. <cffunction name="yearSelectTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a select form control for a range of years based on the supplied `name`."
  143. examples=
  144. '
  145. <!--- View code --->
  146. <cfoutput>
  147. ##yearSelectTag(name="yearOfBirthday", selected=params.yearOfBirthday)##
  148. </cfoutput>
  149. <!--- Only allow selection of year to be for the past 50 years, minimum being 18 years ago --->
  150. <cfset fiftyYearsAgo = Now() - 50>
  151. <cfset eighteenYearsAgo = Now() - 18>
  152. <cfoutput>
  153. ##yearSelectTag(name="yearOfBirthday", selected=params.yearOfBirthday, startYear=fiftyYearsAgo, endYear=eighteenYearsAgo)##
  154. </cfoutput>
  155. '
  156. categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
  157. <cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
  158. <cfargument name="selected" type="string" required="false" default="" hint="The year that should be selected initially.">
  159. <cfargument name="startYear" type="numeric" required="false" hint="See documentation for @dateSelect.">
  160. <cfargument name="endYear" type="numeric" required="false" hint="See documentation for @dateSelect.">
  161. <cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
  162. <cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
  163. <cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
  164. <cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
  165. <cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
  166. <cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
  167. <cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
  168. <cfscript>
  169. $args(name="yearSelectTag", args=arguments);
  170. if (IsNumeric(arguments.selected))
  171. arguments.selected = createDate(arguments.selected, Month(Now()), Day(Now()));
  172. arguments.order = "year";
  173. </cfscript>
  174. <cfreturn dateSelectTags(argumentCollection=arguments)>
  175. </cffunction>
  176. <cffunction name="monthSelectTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a select form control for the months of the year based on the supplied `name`."
  177. examples=
  178. '
  179. <!--- This "Tag" version of the function accepts a `name` and `selected` instead of binding to a model object --->
  180. <cfoutput>
  181. ##monthSelectTag(name="monthOfBirthday", selected=params.monthOfBirthday)##
  182. </cfoutput>
  183. '
  184. categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
  185. <cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
  186. <cfargument name="selected" type="string" required="false" default="" hint="The month that should be selected initially.">
  187. <cfargument name="monthDisplay" type="string" required="false" hint="See documentation for @dateSelect.">
  188. <cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
  189. <cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
  190. <cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
  191. <cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
  192. <cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
  193. <cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
  194. <cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
  195. <cfscript>
  196. $args(name="monthSelectTag", args=arguments);
  197. if (IsNumeric(arguments.selected) and arguments.selected gt 0 and arguments.selected lte 12)
  198. arguments.selected = createDate(Year(Now()), arguments.selected, Day(Now()));
  199. arguments.order = "month";
  200. </cfscript>
  201. <cfreturn dateSelectTags(argumentCollection=arguments)>
  202. </cffunction>
  203. <cffunction name="daySelectTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a select form control for the days of the week based on the supplied `name`."
  204. examples=
  205. '
  206. <!--- This "Tag" version of the function accepts a `name` and `selected` instead of binding to a model object --->
  207. <cfoutput>
  208. ##daySelectTag(name="dayOfWeek", selected=params.dayOfWeek)##
  209. </cfoutput>
  210. '
  211. categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
  212. <cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
  213. <cfargument name="selected" type="string" required="false" default="" hint="The day that should be selected initially.">
  214. <cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
  215. <cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
  216. <cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
  217. <cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
  218. <cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
  219. <cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
  220. <cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
  221. <cfscript>
  222. $args(name="daySelectTag", args=arguments);
  223. if (IsNumeric(arguments.selected) and arguments.selected gt 0 and arguments.selected lte 31)
  224. arguments.selected = createDate(Year(Now()), Month(Now()), arguments.selected);
  225. arguments.order = "day";
  226. </cfscript>
  227. <cfreturn dateSelectTags(argumentCollection=arguments)>
  228. </cffunction>
  229. <cffunction name="hourSelectTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing one select form control for the hours of the day based on the supplied `name`."
  230. examples=
  231. '
  232. <!--- This "Tag" version of the function accepts a `name` and `selected` instead of binding to a model object --->
  233. <cfoutput>
  234. ##hourSelectTag(name="hourOfMeeting", selected=params.hourOfMeeting)##
  235. </cfoutput>
  236. <!--- Show 12 hours instead of 24 --->
  237. <cfoutput>
  238. ##hourSelectTag(name="hourOfMeeting", selected=params.hourOfMeeting, twelveHour=true)##
  239. </cfoutput>
  240. '
  241. categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
  242. <cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
  243. <cfargument name="selected" type="string" required="false" default="" hint="The hour that should be selected initially.">
  244. <cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
  245. <cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
  246. <cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
  247. <cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
  248. <cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
  249. <cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
  250. <cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
  251. <cfargument name="twelveHour" type="boolean" required="false" default="false" hint="See documentation for @timeSelect.">
  252. <cfscript>
  253. $args(name="hourSelectTag", args=arguments);
  254. if (IsNumeric(arguments.selected) and arguments.selected gte 0 and arguments.selected lt 60)
  255. arguments.selected = createTime(arguments.selected, Minute(Now()), Second(Now()));
  256. arguments.order = "hour";
  257. </cfscript>
  258. <cfreturn timeSelectTags(argumentCollection=arguments)>
  259. </cffunction>
  260. <cffunction name="minuteSelectTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing one select form control for the minutes of an hour based on the supplied `name`."
  261. examples=
  262. '
  263. <!--- This "Tag" version of the function accepts a `name` and `selected` instead of binding to a model object --->
  264. <cfoutput>
  265. ##minuteSelectTag(name="minuteOfMeeting", value=params.minuteOfMeeting)##
  266. </cfoutput>
  267. <!--- Only show 15-minute intervals --->
  268. <cfoutput>
  269. ##minuteSelectTag(name="minuteOfMeeting", value=params.minuteOfMeeting, minuteStep=15)##
  270. </cfoutput>
  271. '
  272. categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
  273. <cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
  274. <cfargument name="selected" type="string" required="false" default="" hint="The minute that should be selected initially.">
  275. <cfargument name="minuteStep" type="numeric" required="false" hint="See documentation for @timeSelect.">
  276. <cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
  277. <cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
  278. <cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
  279. <cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
  280. <cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
  281. <cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
  282. <cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
  283. <cfscript>
  284. $args(name="minuteSelectTag", args=arguments);
  285. if (IsNumeric(arguments.selected) and arguments.selected gte 0 and arguments.selected lt 60)
  286. arguments.selected = createTime(Hour(Now()), arguments.selected, Second(Now()));
  287. arguments.order = "minute";
  288. </cfscript>
  289. <cfreturn timeSelectTags(argumentCollection=arguments)>
  290. </cffunction>
  291. <cffunction name="secondSelectTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing one select form control for the seconds of a minute based on the supplied `name`."
  292. examples=
  293. '
  294. <!--- This "Tag" version of the function accepts a `name` and `selected` instead of binding to a model object --->
  295. <cfoutput>
  296. ##secondSelectTag(name="secondsToLaunch", selected=params.secondsToLaunch)##
  297. </cfoutput>
  298. '
  299. categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
  300. <cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
  301. <cfargument name="selected" type="string" required="false" default="" hint="The second that should be selected initially.">
  302. <cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
  303. <cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
  304. <cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
  305. <cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
  306. <cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
  307. <cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
  308. <cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
  309. <cfscript>
  310. $args(name="secondSelectTag", args=arguments);
  311. if (IsNumeric(arguments.selected) and arguments.selected gte 0 and arguments.selected lt 60)
  312. arguments.selected = createTime(Hour(Now()), Minute(Now()), arguments.selected);
  313. arguments.order = "second";
  314. </cfscript>
  315. <cfreturn timeSelectTags(argumentCollection=arguments)>
  316. </cffunction>