PageRenderTime 30ms CodeModel.GetById 21ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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