PageRenderTime 112ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/view/formsplain.cfm

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