Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
can-form
Search
Mihael Konjević
July 11, 2014
Programming
1
520
can-form
Presentation of the can-form plugin -
https://github.com/retro/can-form
Mihael Konjević
July 11, 2014
Tweet
Share
More Decks by Mihael Konjević
See All by Mihael Konjević
Developing (with) Keechma
retro
1
220
File uploading with can.Component and jQuery-file-upload
retro
0
630
JSON Schema and APItizer
retro
2
250
Event Oriented Architecture and Client side apps
retro
2
520
Other Decks in Programming
See All in Programming
Defying Front-End Inertia: Inertia.js on Rails
skryukov
0
370
PHPによる"非"構造化プログラミング入門 -本当に熱いスパゲティコードを求めて- #phperkaigi
o0h
PRO
0
1.2k
PHPのガベージコレクションを深掘りしよう
rinchoku
0
260
WordPress Playground for Developers
iambherulal
0
120
爆速スッキリ! Rspack 移行の成果と道のり - Muddy Web #11
dora1998
1
170
小さく段階的リリースすることで深夜メンテを回避する
mkmk884
2
140
リアルタイムレイトレーシング + ニューラルレンダリング簡単紹介 / Real-Time Ray Tracing & Neural Rendering: A Quick Introduction (2025)
shocker_0x15
1
250
PHPUnit 高速化テクニック / PHPUnit Speedup Techniques
pinkumohikan
1
1.3k
php-fpm がリクエスト処理する仕組みを追う / Tracing-How-php-fpm-Handles-Requests
shin1x1
5
890
地域ITコミュニティの活性化とAWSに移行してみた話
yuukis
0
180
Vibe Codingをせずに Clineを使っている
watany
10
4k
これだけは知っておきたいクラス設計の基礎知識 version 2
masuda220
PRO
18
4.1k
Featured
See All Featured
Facilitating Awesome Meetings
lara
53
6.3k
Testing 201, or: Great Expectations
jmmastey
42
7.4k
The World Runs on Bad Software
bkeepers
PRO
67
11k
Building Applications with DynamoDB
mza
94
6.3k
Designing for humans not robots
tammielis
251
25k
Why Our Code Smells
bkeepers
PRO
336
57k
Music & Morning Musume
bryan
46
6.4k
Producing Creativity
orderedlist
PRO
344
40k
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
Making Projects Easy
brettharned
116
6.1k
Building Adaptive Systems
keathley
41
2.5k
Statistics for Hackers
jakevdp
798
220k
Transcript
can-form Awesome forms for CanJS
Why? • validations and error reporting is a pain •
similar code written over and over again • how do you handle nested object structures?
can-form • can-value is great, use it • behaves like
the can.Component • composable / nestable (allows it to handle nested structures) • validations on the form (validations are bound to context) • simple error reporting and tracking
API FormComponent.extend({ tag : 'simple-form', template : '<content><content>', validate :
{ username : [FormComponent.validationRules.presenceOf()], password : [FormComponent.validationRules.presenceOf()] } }); <simple-form map="{userModel}"> <input type="text" can-value="username"> {{#errors 'username'}} <ul class="bg-danger list-unstyled"> {{#this}} <li>{{ . }}</li> {{/this}} </ul> {{/errors}} <input type="text" can-value="password"> {{#errors 'password'}} <ul class="bg-danger list-unstyled"> {{#this}} <li>{{ . }}</li> {{/this}} </ul> {{/errors}} <button>Submit</button> </simple-form>
API FormComponent.extend({ tag : 'simple-form', template : '<content><content>', validate :
{ username : [FormComponent.validationRules.presenceOf()], password : [FormComponent.validationRules.presenceOf()], 'socialNetworks.*.username' : [FormComponent.validationRules.presenceOf()], 'socialNetworks.*.network' : [FormComponent.validationRules.presenceOf()] } });
API <simple-form map="{userModel}"> <input type="text" can-value="username"> {{#errors 'username'}} <ul class="bg-danger
list-unstyled"> {{#this}} <li>{{ . }}</li> {{/this}} </ul> {{/errors}} … ! {{#each socialNetworks}} <form-for map="{this}" path="socialNetworks.{{@index}}"> <input type="text" can-value="network"> // error reporting code here <input type="text" can-value="username"> // error reporting code here </form-for> {{/each}} <button>Submit</button> </simple-form>
API FormComponent.extend({ tag : 'social-network', template : socialNetworkTemplate, validate :
{ username : [FormComponent.validationRules.presenceOf()], network : [FormComponent.validationRules.presenceOf()] } })
API <simple-form map="{userModel}"> <input type="text" can-value="username"> {{#errors 'username'}} <ul class="bg-danger
list-unstyled"> {{#this}} <li>{{ . }}</li> {{/this}} </ul> {{/errors}} ! … ! {{#each socialNetworks}} <social-network map="{this}" path="socialNetworks.{{@index}}"> </social-network> {{/each}} ! <button>Submit</button> </simple-form>
github.com/retro/can-form @mihaelkonjevic