Skip to content

Commit c583010

Browse files
github-actions[bot]wheels-docs-validator[bot]
andauthored
docs(api): validate View Helpers section (run 25478239817) (wheels-dev#2465)
Co-authored-by: wheels-docs-validator[bot] <wheels-docs-validator@users.noreply.github.com>
1 parent 5dc63d8 commit c583010

93 files changed

Lines changed: 3222 additions & 368 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tools/docs-validation/state.json

Lines changed: 1677 additions & 0 deletions
Large diffs are not rendered by default.

vendor/wheels/public/docs/reference/controller/authenticitytokenfield.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
<!--- Needed here because we're not using `startFormTag`. --->
1+
// 1. Include CSRF token in a plain HTML form that POSTs data
2+
// (use this when you are not using startFormTag())
23
<form action="#urlFor(route='posts')#" method="post">
34
#authenticityTokenField()#
5+
<!--- other fields here --->
6+
</form>
7+
8+
// 2. Not needed for GET forms — GET requests are not CSRF-protected
9+
<form action="#urlFor(route='posts')#" method="get">
10+
<!--- no token required --->
411
</form>
5-
6-
<!--- Not needed here because we're not POSTing the form. --->
7-
<form action="#urlFor(route='invoices')#" method="get">
8-
</form>
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
<!--- Will output: Download CFWheels from <a href="http://cfwheels.org/download">http://cfwheels.org/download</a> --->
2-
#autoLink("Download CFWheels from http://cfwheels.org/download")#
1+
// 1. Link both URLs and email addresses (default behavior)
2+
result = autoLink("Download CFWheels from http://cfwheels.org/download");
3+
// result -> "Download CFWheels from <a href="http://cfwheels.org/download">http://cfwheels.org/download</a>"
34

4-
<!--- Will output: Email us at <a href="mailto:info@cfwheels.org">info@cfwheels.org</a> --->
5-
#autoLink("Email us at info@cfwheels.org")#
5+
// 2. Link email addresses only
6+
result = autoLink(text="Email us at info@cfwheels.org or visit http://cfwheels.org", link="emailAddresses");
7+
// result -> "Email us at <a href="mailto:info@cfwheels.org">info@cfwheels.org</a> or visit http://cfwheels.org"
8+
9+
// 3. Link URLs only (skip email addresses)
10+
result = autoLink(text="Visit http://cfwheels.org or contact info@cfwheels.org", link="URLs");
11+
// result -> "Visit <a href="http://cfwheels.org">http://cfwheels.org</a> or contact info@cfwheels.org"
12+
13+
// 4. Disable auto-linking of relative URLs
14+
result = autoLink(text="See /docs/guide for details or http://cfwheels.org for more.", relative=false);
15+
// result -> "See /docs/guide for details or <a href="http://cfwheels.org">http://cfwheels.org</a> for more."
Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1-
<!--- View Code --->
2-
#startFormTag(action="something")#
3-
<!--- Form Controls go here --->
4-
#buttonTag(content="Submit this form", value="save")#
1+
// 1. Basic submit button inside a form
2+
#startFormTag(action="create")#
3+
#buttonTag(content="Save changes", value="save")#
54
#endFormTag()#
5+
<!--- Produces: <button type="submit" value="save">Save changes</button> --->
6+
7+
// 2. Reset button to clear form fields
8+
#buttonTag(content="Clear form", type="reset")#
9+
<!--- Produces: <button type="reset" value="save">Clear form</button> --->
10+
11+
// 3. Plain button (no form submission) with a CSS class and id
12+
#buttonTag(content="Open dialog", type="button", value="open", class="btn btn-secondary", id="openDialogBtn")#
13+
<!--- Produces: <button type="button" value="open" class="btn btn-secondary" id="openDialogBtn">Open dialog</button> --->
14+
15+
// 4. Submit button wrapped in a paragraph using prepend and append
16+
#buttonTag(content="Submit", value="submit", prepend="<p>", append="</p>")#
17+
<!--- Produces: <p><button type="submit" value="submit">Submit</button></p> --->
18+
19+
// 5. Image button (renders an img tag inside the button element)
20+
#buttonTag(content="", image="submit-icon.png", value="save")#
21+
<!--- Produces: <button type="submit" value="save"><img src="/images/submit-icon.png" alt="Submit Icon" /></button> --->
Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
#buttonTo(text="Delete Account", action="perFormDelete", disable="Wait...")#
1+
// 1. Basic button that submits to a controller/action
2+
#buttonTo(text="Delete Account", controller="account", action="delete")#
3+
<!--- Outputs: <form action="/account/delete" method="post"><button type="submit">Delete Account</button></form> --->
24

3-
<!--- apply attributes to the input element by prefixing any arguments with "input"--->
4-
#buttonTo(text="Edit", action="edit", inputId="edit-button", inputClass="edit-button-class")#
5+
// 2. If you're already in the `account` controller, CFWheels will assume the current controller
6+
#buttonTo(text="Delete Account", action="delete")#
7+
<!--- Outputs: <form action="/account/delete" method="post"><button type="submit">Delete Account</button></form> --->
8+
9+
// 3. Use `method` to send a DELETE request (a hidden `_method` field is added automatically)
10+
#buttonTo(text="Remove Post", controller="blog", action="delete", key=99, method="delete")#
11+
<!--- Outputs: <form action="/blog/delete/99" method="post"><input type="hidden" name="_method" value="delete" /><button type="submit">Remove Post</button></form> --->
12+
13+
// 4. Use a named route configured in `config/routes.cfm`
14+
#buttonTo(text="Archive", route="archivePost", postId=12)#
15+
16+
// 5. Show a "please wait" state by disabling the button on click — pass extra attributes to the button using the `input` prefix
17+
#buttonTo(text="Place Order", action="checkout", inputId="checkout-btn", inputClass="btn btn-primary", inputData-disable-with="Processing...")#
18+
19+
// 6. Use an image instead of text for the button
20+
#buttonTo(image="icons/trash.png", action="destroy", key=params.id, method="delete")#
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
<!--- Basic example of a check box for a boolean field --->
1+
// 1. Basic check box bound to a boolean model property
22
#checkBox(objectName="photo", property="isPublic", label="Display this photo publicly.")#
33

4-
<!--- Shows check boxes for selecting public access for all photos provided by the `photos` association and nested properties --->
4+
// 2. Custom checked and unchecked values (e.g. "yes" / "no" instead of 1 / 0)
5+
#checkBox(objectName="user", property="agreedToTerms", checkedValue="yes", uncheckedValue="no", label="I agree to the terms of service.")#
6+
7+
// 3. Check boxes for a nested association (photos belonging to a user)
58
<cfloop from="1" to="#ArrayLen(user.photos)#" index="i">
6-
<div>
7-
<h3>#user.photos[i].title#:</h3>
8-
<div>
9-
#checkBox(objectName="user", association="photos", position=i, property="isPublic", label="Display this photo publicly.")#
10-
</div>
11-
</div>
12-
</cfloop>
9+
#checkBox(objectName="user", association="photos", position=i, property="isPublic", label="Make public: #user.photos[i].title#")#
10+
</cfloop>
Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
1-
<!--- Example 1: Basic usage involves a `label`, `name`, and `value` --->
2-
#checkBoxTag(name="subscribe", value="true", label="Subscribe to our newsletter", checked=false)#
1+
// 1. Basic usage with a label and a pre-checked state
2+
<cfoutput>
3+
#checkBoxTag(name="subscribe", value="1", label="Subscribe to our newsletter", checked=true)#
4+
</cfoutput>
35

4-
<!--- Example 2: Loop over a query to display choices and whether or not they are checked --->
5-
// Controller code
6-
pizza = model("pizza").findByKey(session.pizzaId);
7-
selectedToppings = pizza.toppings();
8-
toppings = model("topping").findAll(order="name");
6+
// 2. Render an unchecked check box that also submits a value when unchecked
7+
<cfoutput>
8+
#checkBoxTag(name="agreeToTerms", value="1", uncheckedValue="0", label="I agree to the terms")#
9+
</cfoutput>
910

10-
<!--- View code --->
11-
<fieldset>
12-
<legend>Toppings</legend>
13-
<cfoutput query="toppings">
14-
#checkBoxTag(name="toppings", value="true", label=toppings.name, checked=YesNoFormat(ListFind(ValueList(selectedToppings.id), toppings.id))#
15-
</cfoutput>
16-
</fieldset>
11+
// 3. Loop over a query to render one check box per option, checking those already selected
12+
// Controller
13+
toppings = model("Topping").findAll(order="name");
14+
selectedIds = "2,5,9"; // e.g. previously saved topping IDs as a comma-delimited list
15+
16+
// View
17+
<cfoutput query="toppings">
18+
#checkBoxTag(
19+
name = "toppingIds",
20+
value = toppings.id,
21+
label = toppings.name,
22+
checked = listFindNoCase(selectedIds, toppings.id) GT 0
23+
)#
24+
</cfoutput>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// 1. Basic color picker bound to a model object property
2+
#colorField(objectName="product", property="themeColor")#
3+
4+
// 2. Color picker with a custom label and a CSS class
5+
#colorField(objectName="user", property="profileColor", label="Profile Color", class="color-picker")#
6+
7+
// 3. Color pickers for nested properties on a hasMany association (e.g., palette swatches)
8+
<cfloop from="1" to="#ArrayLen(design.swatches)#" index="i">
9+
#colorField(objectName="design", association="swatches", position="#i#", property="hexValue", label="Swatch ##i#")#
10+
</cfloop>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// 1. Basic color picker with a default value
2+
#colorFieldTag(name="brandColor", value="##FF5733")#
3+
4+
// 2. Color picker with a label and a CSS class
5+
#colorFieldTag(name="themeColor", value="##336699", label="Theme Color", class="color-input")#
6+
7+
// 3. Color picker with label placement and prepend/append wrappers
8+
#colorFieldTag(name="highlightColor", label="Highlight", labelPlacement="before", prepend="<div class=""field"">", append="</div>")#
Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,43 @@
1-
<!--- In your view --->
1+
// 1. Store sidebar content for use in the layout
22
<cfsavecontent variable="mySidebar">
3-
<h1>My Sidebar Text</h1>
3+
<nav>Recent Posts</nav>
44
</cfsavecontent>
55
<cfset contentFor(sidebar=mySidebar)>
66

7-
<!--- In your layout --->
8-
<html>
9-
<head>
10-
<title>My Site</title>
11-
</head>
12-
<body>
13-
<cfoutput>
14-
#includeContent("sidebar")#
15-
#includeContent()#
16-
</cfoutput>
17-
</body>
18-
</html>
7+
<!--- In your layout, output the stored section --->
8+
<cfoutput>
9+
#includeContent("sidebar")#
10+
#includeContent()#
11+
</cfoutput>
12+
13+
// 2. Push content onto a stack — multiple calls append by default
14+
<cfsavecontent variable="firstScript">
15+
<script src="/js/base.js"></script>
16+
</cfsavecontent>
17+
<cfset contentFor(scripts=firstScript)>
18+
19+
<cfsavecontent variable="secondScript">
20+
<script src="/js/page.js"></script>
21+
</cfsavecontent>
22+
<cfset contentFor(scripts=secondScript)>
23+
24+
<!--- Both scripts are rendered in order --->
25+
<cfoutput>#includeContent("scripts")#</cfoutput>
26+
27+
// 3. Prepend content to an existing section using position="first"
28+
<cfsavecontent variable="criticalScript">
29+
<script src="/js/critical.js"></script>
30+
</cfsavecontent>
31+
<cfset contentFor(position="first", scripts=criticalScript)>
32+
33+
// 4. Overwrite an entire section with overwrite="all"
34+
<cfsavecontent variable="replacementSidebar">
35+
<nav>Admin Sidebar</nav>
36+
</cfsavecontent>
37+
<cfset contentFor(overwrite="all", sidebar=replacementSidebar)>
38+
39+
// 5. Overwrite a specific position in the stack (position=1, overwrite=true)
40+
<cfsavecontent variable="updatedScript">
41+
<script src="/js/updated.js"></script>
42+
</cfsavecontent>
43+
<cfset contentFor(position=1, overwrite=true, scripts=updatedScript)>

0 commit comments

Comments
 (0)