You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/index.md
+1-5
Original file line number
Diff line number
Diff line change
@@ -13,13 +13,9 @@ ChameleonForms takes away the pain and repetition of building forms with ASP.NET
13
13
14
14
It's ideally suited for situations where you want to **quickly** build forms that are highly consistent and maintainable. If you are trying to build highly specialised forms that are individually, painstakingly crafted then that's not what this library is for. That's where it makes sense to break out your JavaScript library of choice.
15
15
16
-
Here's a quick example of what ChameleonForms looks like compared to a traditional ASP.NET MVC approach:
17
-
18
-

Copy file name to clipboardexpand all lines: docs/templates/chameleonforms/partials/home.tmpl.partial
+1-1
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,6 @@
11
11
<div class="clearfix"></div>
12
12
<div class="lead-title">Shape-shifting your forms experience in ASP.NET Core.</div>
13
13
<div class="sub-lead-title">ChameleonForms makes building consistent, correct forms that work well client-side and server-side easy and quick by using model-driven defaults, conventions, templates and terse, declarative, type-safe syntax.</div>
Copy file name to clipboardexpand all lines: index.md
+302
Original file line number
Diff line number
Diff line change
@@ -73,11 +73,313 @@ Here are the things that ChameleonForms has done for us based on the model:
73
73
74
74
Other model-driven form features you can explore:
75
75
76
+
*[Getting started](docs/getting-started.md)
76
77
* Inference from model type to output [Boolean fields](docs/boolean.md), [DateTime fields](docs/datetime.md), [Enum fields](docs/enum.md), [List fields](docs/list.md), [File upload fields](docs/file-upload.md) and [Number fields](docs/number.md)
77
78
* Multiple-select: [Flags enum fields](docs/flags-enum.md), [Multiple-select enum fields](docs/multiple-enum.md) and [Multiple-select list fields](docs/multiple-list.md)
78
79
* Inference from model property attributes to output [Textarea fields](docs/textarea.md), [Password fields](docs/password.md), [Email fields](docs/email.md) and [Uri fields](docs/uri.md) as well as supporting controlling the client-side and server-side validation of [DateTime fields](docs/datetime.md)
80
+
* Client-side and server-side validation is given to us from the model metadata based on the [built-in ASP.NET Core MVC features](https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation?view=aspnetcore-3.1).
81
+
* The HTML that is rendered will always bind correctly to the view model on the ASP.NET Core MVC controller using the [built-in model binding](https://docs.microsoft.com/en-us/aspnet/core/mvc/models/model-binding?view=aspnetcore-3.1).
79
82
80
83
***
81
84
82
85
</div>
83
86
</div>
87
+
88
+
<p> </p>
89
+
<p> </p>
90
+
91
+
92
+
<divclass="row">
93
+
<divclass="col-md-4">
94
+
<h2>Rapid, consistent, correct forms</h2>
95
+
<p>Use terse, declarative, type-safe, intellisense-friendly syntax to quickly define your forms and let conventions and templates take care of the detail so you don't have to.</p>
96
+
<p>Your forms will be quicker to write and easier to maintain and you won't get stuck writing the same form boilerplate markup form after form after form. Plus, you can build in accessibility and consistency as cross-cutting concerns.</p>
97
+
<p><strong>ChameleonForms really shines when you need to build a lot of forms quickly and consistently.</strong></p>
98
+
</div>
99
+
<divclass="col-md-8">
100
+
101
+
102
+
# [View (TH)](#tab/rapid-1)
103
+
104
+
**Tag helpers variant**
105
+
106
+
```cshtml
107
+
@model SignupViewModel
108
+
<h1>Account signup</h1>
109
+
<chameleon-form attr-id="signup-form">
110
+
<form-message type="Information" heading="Signup for an account">
111
+
<message-paragraph>Please fill in your information below to signup for an account.</message-paragraph>
112
+
</form-message>
113
+
114
+
<form-section heading="Your details">
115
+
<field for="FirstName" />
116
+
<field for="LastName" />
117
+
<field for="DateOfBirth" hint="DD/MM/YYYY" />
118
+
</form-section>
119
+
120
+
<form-section heading="Account details">
121
+
<field for="EmailAddress" hint="An email will be sent to this address to confirm you own it" />
122
+
<field for="Password" />
123
+
<field for="MembershipType" />
124
+
</form-section>
125
+
126
+
<form-section heading="Additional details">
127
+
<field for="Bio" />
128
+
<field for="Homepage" placeholder="https://" />
129
+
</form-section>
130
+
131
+
<form-message type="Action" heading="Confirm the Terms & Conditions">
132
+
<message-paragraph>Please <a href="#">read the terms and conditions</a></message-paragraph>
133
+
<field-element for="TermsAndConditions" inline-label="I agree to the terms and conditions" />
<inputclass="form-control"data-val="true"data-val-required="The First name field is required."id="FirstName"name="FirstName"required="required"type="text"value="" />
<inputclass="form-control"data-val="true"data-val-required="The Last name field is required."id="LastName"name="LastName"required="required"type="text"value="" />
<labelclass="control-label"for="DateOfBirth">Date of birth</label>
231
+
<divclass="input-group">
232
+
<inputaria-describedby="DateOfBirth--Hint"class="form-control"data-val="true"data-val-date="The field Date of birth must be a date with format d/M/yyyy."data-val-format="d/M/yyyy"data-val-required="The Date of birth field is required."id="DateOfBirth"name="DateOfBirth"required="required"type="text"value="" />
<inputaria-describedby="EmailAddress--Hint"class="form-control"data-val="true"data-val-email="The Email address field is not a valid e-mail address."data-val-required="The Email address field is required."id="EmailAddress"name="EmailAddress"required="required"type="email"value="" />
247
+
<divclass="input-group-addon required">
248
+
<emclass="required"title="Required">∗</em>
249
+
</div>
250
+
</div>
251
+
<divclass="help-block form-hint"id="EmailAddress--Hint">An email will be sent to this address to confirm you own it</div>
<inputclass="form-control"data-val="true"data-val-required="The Password field is required."id="Password"name="Password"required="required"type="password" />
<selectclass="form-control"data-val="true"data-val-required="The Membership type field is required."id="MembershipType"name="MembershipType"required="required">
<h4class="panel-title">Confirm the Terms & Conditions</h4>
297
+
</div>
298
+
<divclass="panel-body">
299
+
<p>
300
+
Please
301
+
<ahref="#">read the terms and conditions</a>
302
+
</p>
303
+
<inputdata-val="true"data-val-required="The Terms and conditions field is required."id="TermsAndConditions"name="TermsAndConditions"required="required"type="checkbox"value="true" />
304
+
<labelfor="TermsAndConditions">I agree to the terms and conditions</label>
Here are the things that ChameleonForms has done for us:
363
+
364
+
* We've been able to declaratively declare the structure of the form rather than the presentation of the form - this is akin to the separation we get from declarative HTML separated from CSS and JS.
365
+
* The resulting markup for the form itself, the user messages, form sections, fields and navigation have all been sorted out, consistently, for us using a form template we've been able to select in `Startup.cs` (in this case using Bootstrap). The amount of HTML that is required to render that form (see HTML output tab) is a lot - it's easy to parts of that wrong if you need to specify the boilerplate manually, plus it then couples all of your forms to that specific template. With ChameleonForms we can swap out the template with a single line of code, for instance when you want to switch from Bootstrap to a more customised setup if you make it big and want to add some bespoke design love.
366
+
* All of the syntax is type-safe and thus benefits from a combination of intellisense to speed up writing and protection from runtime mistakes (e.g. id mismatches etc.). We also know that the form will definitely correctly bind to the view model on the server-side MVC controller without needing to perform slow UI or manual tests.
367
+
* All fields automatically have a combination of server-side validation and client-side validation logic and messages added in for us built on top of the ASP.NET Core MVC features.
368
+
* All fields are easily and tersely configurable to include hints and other tweaks to the rendered markup using typesafe / intellisense code.
369
+
370
+
Documentation worth exploring to dive into more detail includes:
*[Using different form templates](docs/form-templates.md) and [creating custom form templates](docs/custom-template.md)
378
+
379
+
***
380
+
381
+
</div>
382
+
</div>
383
+
384
+
<p> </p>
385
+
<pclass="home-buttons"><ahref="docs/index.md"class="btn btn-primary btn-lg">Tell me more?!</a> <ahref="docs/getting-started.md"class="btn btn-primary btn-lg">I want to get started!</a></p>
0 commit comments