Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

add an example showing how to access form post params #122

Open
wants to merge 1 commit into from

1 participant

@cap10morgan

It required quite a bit of trial and error to figure this out. So I figured I'd save future users the trouble. Especially since handling forms is a pretty common thing to do in web apps.

@shimaore shimaore referenced this pull request in zappajs/zappajs
Closed

Backporting maurimach/zappa's pull requests #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 0 deletions.
  1. +22 −0 examples/form_post.coffee
View
22 examples/form_post.coffee
@@ -0,0 +1,22 @@
+require('zappa') ->
+ @enable 'default layout'
+ @use 'bodyParser'
+
+ @get '/': ->
+ @render index: {}
+
+ @post '/widgets': ->
+ @render widgets: { form: @body }
+
+ @view index: ->
+ @title = 'My Form'
+ h1 @title
+ form method: 'post', action: '/widgets', ->
+ input id: 'widget_name', type: 'text', name: 'widget_name',
+ placeholder: 'widget name', size: 50
+ button 'create widget'
+
+ @view bundles: ->
+ @title = 'Widgets'
+ h1 @title
+ p @form.widget_name
Something went wrong with that request. Please try again.