methodarguments, depending on the route that you're sending the form to. Also, if the route expects any parameters, you must pass those in as arguments to startFormTag as well. If you haven't already, read up about routes in the Routing chapter.
config/routes.cfmmay look something like this:
config/routes.cfm. What matters is that you know the names, methods, and parameters that the routes expect. (With some practice, you'll probably be able to look at
config/routes.cfmand know exactly what the names, methods, and parameters are though.)
POSTmethod. That happens to be the default for startFormTag(), so you don't even need to include the
methodargument. You can then pass the
usersroute name to the
methodargument as listed in your routes:
userroute expects a
keyparameter, so that is passed into
POSTrequests, so how does CFWheels also enable
method="post"on the form to send
DELETErequests. But the CFWheels router will recognize a
DELETErequest if a form variable called
_methodis also sent, specifying the
<form>tag generated along with a
patchwill look something like this:
<form>tag that must
POSTdata, be sure to add your own hidden fields for
_methodand use the authenticityTokenField() helper to generate the hidden field for the
authenticityTokenthat CFWheels will require on the
labelPlacementarguments, you can make the form code ever simpler across your whole application.
departmentIdproperties and a query object named
departmentsthat contains identifier and text values. Note that the instance variable is named
profile, though the model itself doesn't necessarily need to be named
profile(for example, created by new(), the form will display blank values for all the fields. If you pass it an object created by a finder like findOne() or findByKey(), then the form will display the values provided through the object. This allows for us to potentially use the same view file for both create and update scenarios in our application.
departmentIdin conventional ways (camel case), CFWheels will generate the labels for us automatically:
lastName. The user didn't enter either. So in the controller's
updateaction, it loads the model object, sets the values that the user submitted, sees that there was a validation error after calling update(), and displays the form view again.
updateaction may look something like this:
profileobject as list items in that unordered list.
<div class="fieldWithErrors">HTML tag for you to enrich with your ninja CSS skills.
departmentIdfields. That's all it takes to display the corresponding error messages of each form control on your form.
<select>list with options. What's really cool about this helper is that it can populate the
<option>s with values from a query, struct, or array.
departmentsvariable passed to the options argument contains a query, struct, or array of department data that should be selectable in the drop-down.
optionsand intelligently pick out elements to populate for the
<option>s' values and text.
valueand the first non-numeric column for the display text. The order of the columns is determined how you have them defined in your database.
valueand the values as the display text.
valueand display text with the elements. When it's a 2D array, CFWheels will use each item's first element as the
valueand each element's second element as the display text. For anything larger than 2 dimensions, CFWheels only uses the first 2 sub-elements and ignores the rest.
<option>s' values and display text with specific columns, you should pass the names of the columns to use as the
eyeColorto power the possible values:
profile.eyeColorId's value were already set to
1, the rendered HTML would appear similar to this:
accountobject that the fields are bound to. Let's say that you always wanted this behavior to happen when the form for a new account loads. You can do something like this in the controller:
Tagto the end of the function name and use the
selectedarguments instead of the
propertyarguments that you normally use.
labelelement; you can do so by passing in
labelClass="class-name". CFWheels will detect that your argument starts with "label" and assume it should go on the
labelelement and not the
inputelement (or whatever "main" element the form helper creates). This means you could also pass in
labelId="my-id"to set the
true, and CFWheels will include the boolean attribute:
dataattributes in HTML usually look something like this:
data-ajax-urlHTML attribute as depicted above. All you need to do is pass in an argument named
dataAjaxUrl, and CFWheels will convert that attribute name to the hyphenated version in the HTML output.
data_ajax_urlinstead if you prefer underscores, and it will produce the same result.
DATE, TIMESTAMP, DATETIME, etc.