PageRenderTime 54ms CodeModel.GetById 30ms app.highlight 4ms RepoModel.GetById 16ms app.codeStats 1ms

/wheels/view/formsplain.cfm

http://cfwheels.googlecode.com/
ColdFusion | 286 lines | 275 code | 8 blank | 3 comment | 40 complexity | fd6bf9b8aee82bdbbdca4b2ef32be15d MD5 | raw file
  1<cffunction name="textFieldTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a text field form control based on the supplied `name`. Note: Pass any additional arguments like `class`, `rel`, and `id`, and the generated tag will also include those values as HTML attributes."
  2	examples=
  3	'
  4		<!--- Basic usage usually involves a `label`, `name`, and `value` --->
  5		<cfoutput>
  6		    ##textFieldTag(label="Search", name="q", value=params.q)##
  7		</cfoutput>
  8	'
  9	categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
 10	<cfargument name="name" type="string" required="true" hint="Name to populate in tag's `name` attribute.">
 11	<cfargument name="value" type="string" required="false" default="" hint="Value to populate in tag's `value` attribute.">
 12	<cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
 13	<cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
 14	<cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
 15	<cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
 16	<cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
 17	<cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
 18	<cfscript>
 19		var loc = {};
 20		$args(name="textFieldTag", args=arguments);
 21		arguments.property = arguments.name;
 22		arguments.objectName = {};
 23		arguments.objectName[arguments.name] = arguments.value;
 24		StructDelete(arguments, "name");
 25		StructDelete(arguments, "value");
 26		loc.returnValue = textField(argumentCollection=arguments);
 27	</cfscript>
 28	<cfreturn loc.returnValue>
 29</cffunction>
 30
 31<cffunction name="passwordFieldTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a password field form control based on the supplied `name`. Note: Pass any additional arguments like `class`, `rel`, and `id`, and the generated tag will also include those values as HTML attributes."
 32	examples=
 33	'
 34		<!--- Basic usage usually involves a `label`, `name`, and `value` --->
 35		<cfoutput>
 36		    ##passwordFieldTag(label="Password", name="password", value=params.password)##
 37		</cfoutput>
 38	'
 39	categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
 40	<cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
 41	<cfargument name="value" type="string" required="false" default="" hint="See documentation for @textFieldTag.">
 42	<cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
 43	<cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
 44	<cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
 45	<cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
 46	<cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
 47	<cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
 48	<cfscript>
 49		var loc = {};
 50		$args(name="passwordFieldTag", args=arguments);
 51		arguments.property = arguments.name;
 52		arguments.objectName = {};
 53		arguments.objectName[arguments.name] = arguments.value;
 54		StructDelete(arguments, "name");
 55		StructDelete(arguments, "value");
 56		loc.returnValue = passwordField(argumentCollection=arguments);
 57	</cfscript>
 58	<cfreturn loc.returnValue>
 59</cffunction>
 60
 61<cffunction name="hiddenFieldTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a hidden field form control based on the supplied `name`. Note: Pass any additional arguments like `class`, `rel`, and `id`, and the generated tag will also include those values as HTML attributes."
 62	examples=
 63	'
 64		<!--- Basic usage usually involves a `name` and `value` --->
 65		<cfoutput>
 66		    ##hiddenFieldTag(name="userId", value=user.id)##
 67		</cfoutput>
 68	'
 69	categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
 70	<cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
 71	<cfargument name="value" type="string" required="false" default="" hint="See documentation for @textFieldTag.">
 72	<cfscript>
 73		var loc = {};
 74		arguments.property = arguments.name;
 75		arguments.objectName = {};
 76		arguments.objectName[arguments.name] = arguments.value;
 77		StructDelete(arguments, "name");
 78		StructDelete(arguments, "value");
 79		loc.returnValue = hiddenField(argumentCollection=arguments);
 80	</cfscript>
 81	<cfreturn loc.returnValue>
 82</cffunction>
 83
 84<cffunction name="fileFieldTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a file form control based on the supplied `name`. Note: Pass any additional arguments like `class`, `rel`, and `id`, and the generated tag will also include those values as HTML attributes."
 85	examples=
 86	'
 87		<!--- Basic usage usually involves a `label`, `name`, and `value` --->
 88		<cfoutput>
 89		    ##fileFieldTag(label="Photo", name="photo", value=params.photo)##
 90		</cfoutput>
 91	'
 92	categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
 93	<cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
 94	<cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
 95	<cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
 96	<cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
 97	<cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
 98	<cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
 99	<cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
100	<cfscript>
101		var loc = {};
102		$args(name="fileFieldTag", args=arguments);
103		arguments.property = arguments.name;
104		arguments.objectName = {};
105		arguments.objectName[arguments.name] = "";
106		StructDelete(arguments, "name");
107		loc.returnValue = fileField(argumentCollection=arguments);
108	</cfscript>
109	<cfreturn loc.returnValue>
110</cffunction>
111
112<cffunction name="textAreaTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a text area form control based on the supplied `name`. Note: Pass any additional arguments like `class`, `rel`, and `id`, and the generated tag will also include those values as HTML attributes."
113	examples=
114	'
115		<!--- Basic usage usually involves a `label`, `name`, and `password` --->
116		<cfoutput>
117		    ##textAreaTag(label="Description", name="description", value=params.description)##
118		</cfoutput>
119	'
120	categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
121	<cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
122	<cfargument name="content" type="string" required="false" default="" hint="Content to display in `textarea` on page load.">
123	<cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
124	<cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
125	<cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
126	<cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
127	<cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
128	<cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
129	<cfscript>
130		var loc = {};
131		$args(name="textAreaTag", args=arguments);
132		arguments.property = arguments.name;
133		arguments.objectName = {};
134		arguments.objectName[arguments.name] = arguments.content;
135		StructDelete(arguments, "name");
136		StructDelete(arguments, "content");
137		loc.returnValue = textArea(argumentCollection=arguments);
138	</cfscript>
139	<cfreturn loc.returnValue>
140</cffunction>
141
142<cffunction name="radioButtonTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a radio button form control based on the supplied `name`. Note: Pass any additional arguments like `class`, `rel`, and `id`, and the generated tag will also include those values as HTML attributes."
143	examples=
144	'
145		<!--- Basic usage usually involves a `label`, `name`, `value`, and `checked` value --->
146		<cfoutput>
147		    <fieldset>
148				<legend>Gender</legend>
149			    ##radioButtonTag(name="gender", value="m", label="Male", checked=true)##<br />
150		        ##radioButtonTag(name="gender", value="f", label="Female")##
151			</fieldset>
152		</cfoutput>
153	'
154	categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
155	<cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
156	<cfargument name="value" type="string" required="true" hint="See documentation for @textFieldTag.">
157	<cfargument name="checked" type="boolean" required="false" default="false" hint="Whether or not to check the radio button by default.">
158	<cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
159	<cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
160	<cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
161	<cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
162	<cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
163	<cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
164	<cfscript>
165		var loc = {};
166		$args(name="radioButtonTag", args=arguments);
167		arguments.property = arguments.name;
168		arguments.objectName = {};
169		if (arguments.checked)
170		{
171			arguments.objectName[arguments.name] = arguments.value;
172			arguments.tagValue = arguments.value;
173		}
174		else
175		{
176			arguments.objectName[arguments.name] = "";
177			arguments.tagValue = arguments.value;
178		}
179		StructDelete(arguments, "name");
180		StructDelete(arguments, "value");
181		StructDelete(arguments, "checked");
182		loc.returnValue = radioButton(argumentCollection=arguments);
183	</cfscript>
184	<cfreturn loc.returnValue>
185</cffunction>
186
187<cffunction name="checkBoxTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a check box form control based on the supplied `name`. Note: Pass any additional arguments like `class`, `rel`, and `id`, and the generated tag will also include those values as HTML attributes."
188	examples=
189	'
190		<!--- Example 1: Basic usage involves a `label`, `name`, and `value` --->
191		<cfoutput>
192		    ##checkBoxTag(name="subscribe", value="true", label="Subscribe to our newsletter", checked=false)##
193		</cfoutput>
194		
195		<!--- Example 2: Loop over a query to display choices and whether or not they are checked --->
196		<!--- - Controller code --->
197		<cfset pizza = model("pizza").findByKey(session.pizzaId)>
198		<cfset selectedToppings = pizza.toppings()>
199		<cfset toppings = model("topping").findAll(order="name")>
200		
201		<!--- View code --->
202		<fieldset>
203			<legend>Toppings</legend>
204			<cfoutput query="toppings">
205				##checkBoxTag(name="toppings", value="true", label=toppings.name, checked=YesNoFormat(ListFind(ValueList(selectedToppings.id), toppings.id))##
206			</cfoutput>
207		</fieldset>
208	'
209	categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,selectTag,dateTimeSelectTag,dateSelectTag,timeSelectTag">
210	<cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
211	<cfargument name="checked" type="boolean" required="false" default="false" hint="Whether or not the check box should be checked by default.">
212	<cfargument name="value" type="string" required="false" hint="Value of check box in its `checked` state.">
213	<cfargument name="uncheckedValue" type="string" required="false" default="" hint="The value of the check box when it's on the `unchecked` state.">
214	<cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
215	<cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
216	<cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
217	<cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
218	<cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
219	<cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
220	<cfscript>
221		var loc = {};
222		$args(name="checkBoxTag", args=arguments);
223		arguments.checkedValue = arguments.value;
224		arguments.property = arguments.name;
225		arguments.objectName = {};
226		if (arguments.checked)
227			arguments.objectName[arguments.name] = arguments.value;
228		else
229			arguments.objectName[arguments.name] = "";
230		if (!StructKeyExists(arguments, "id"))
231		{
232			loc.valueToAppend = LCase(Replace(ReReplaceNoCase(arguments.checkedValue, "[^a-z0-9- ]", "", "all"), " ", "-", "all"));
233			arguments.id = $tagId(arguments.objectName, arguments.property);
234			if (len(loc.valueToAppend))
235				arguments.id = arguments.id & "-" & loc.valueToAppend;
236		}
237		StructDelete(arguments, "name");
238		StructDelete(arguments, "value");
239		StructDelete(arguments, "checked");
240		loc.returnValue = checkBox(argumentCollection=arguments);
241	</cfscript>
242	<cfreturn loc.returnValue>
243</cffunction>
244
245<cffunction name="selectTag" returntype="string" access="public" output="false" hint="Builds and returns a string containing a select form control based on the supplied `name` and `options`. Note: Pass any additional arguments like `class`, `rel`, and `id`, and the generated tag will also include those values as HTML attributes."
246	examples=
247	'
248		<!--- Controller code --->
249		<cfset cities = model("city").findAll()>
250
251		<!--- View code --->
252		<cfoutput>
253		    ##selectTag(name="cityId", options=cities)##
254		</cfoutput>
255		
256		<!--- Do this when Wheels isn''t grabbing the correct values for the `option`s'' values and display texts --->
257		<cfoutput>
258			##selectTag(name="cityId", options=cities, valueField="id", textField="name")##
259		</cfoutput>
260	'
261	categories="view-helper,forms-plain" chapters="form-helpers-and-showing-errors" functions="URLFor,startFormTag,endFormTag,submitTag,textFieldTag,radioButtonTag,checkBoxTag,passwordFieldTag,hiddenFieldTag,textAreaTag,fileFieldTag,dateTimeSelectTags,dateSelectTags,timeSelectTags">
262	<cfargument name="name" type="string" required="true" hint="See documentation for @textFieldTag.">
263	<cfargument name="options" type="any" required="true" hint="See documentation for @select.">
264	<cfargument name="selected" type="string" required="false" default="" hint="Value of option that should be selected by default.">
265	<cfargument name="includeBlank" type="any" required="false" hint="See documentation for @select.">
266	<cfargument name="multiple" type="boolean" required="false" hint="Whether to allow multiple selection of options in the select form control.">
267	<cfargument name="valueField" type="string" required="false" hint="See documentation for @select.">
268	<cfargument name="textField" type="string" required="false" hint="See documentation for @select.">
269	<cfargument name="label" type="string" required="false" hint="See documentation for @textField.">
270	<cfargument name="labelPlacement" type="string" required="false" hint="See documentation for @textField.">
271	<cfargument name="prepend" type="string" required="false" hint="See documentation for @textField.">
272	<cfargument name="append" type="string" required="false" hint="See documentation for @textField.">
273	<cfargument name="prependToLabel" type="string" required="false" hint="See documentation for @textField.">
274	<cfargument name="appendToLabel" type="string" required="false" hint="See documentation for @textField.">
275	<cfscript>
276		var loc = {};
277		$args(name="selectTag", args=arguments);
278		arguments.property = arguments.name;
279		arguments.objectName = {};
280		arguments.objectName[arguments.name] = arguments.selected;
281		StructDelete(arguments, "name");
282		StructDelete(arguments, "selected");
283		loc.returnValue = select(argumentCollection=arguments);
284	</cfscript>
285	<cfreturn loc.returnValue>
286</cffunction>