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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Mihael Konjević
July 11, 2014
Programming
580
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
can-form
Presentation of the can-form plugin -
https://github.com/retro/can-form
Mihael Konjević
July 11, 2014
More Decks by Mihael Konjević
See All by Mihael Konjević
Developing (with) Keechma
retro
1
280
File uploading with can.Component and jQuery-file-upload
retro
0
670
JSON Schema and APItizer
retro
2
300
Event Oriented Architecture and Client side apps
retro
2
630
Other Decks in Programming
See All in Programming
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
130
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
8.2k
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
300
JavaDoc 再入門
nagise
1
420
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
300
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
AIで効率化できた業務・日常
ochtum
0
150
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
190
The NotImplementedError Problem in Ruby
koic
1
950
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
840
さぁV100、メモリをお食べ・・・
nilpe
0
160
Featured
See All Featured
Designing Experiences People Love
moore
143
24k
Faster Mobile Websites
deanohume
310
32k
Music & Morning Musume
bryan
47
7.2k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
310
Navigating Team Friction
lara
192
16k
The Spectacular Lies of Maps
axbom
PRO
1
820
From π to Pie charts
rasagy
0
220
Optimising Largest Contentful Paint
csswizardry
37
3.7k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
640
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
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