Created
June 5, 2013 09:50
-
-
Save txus/5712825 to your computer and use it in GitHub Desktop.
Disabled and checked checkboxes aren't sent in post requests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # app.rb | |
| # | |
| # Usage: | |
| # | |
| # $ gem install sinatra | |
| # $ ruby app.rb | |
| # | |
| require 'sinatra' | |
| get '/' do | |
| erb :index | |
| end | |
| post '/foo' do | |
| puts params # {"checked"=>"on", "submit"=>"Send"} | |
| end | |
| __END__ | |
| @@ layout | |
| <html> | |
| <%= yield %> | |
| </html> | |
| @@ index | |
| <h1>Hello</h1> | |
| <form action="/foo" method="post"> | |
| <input type="checkbox" name="checked" checked="true">Checked</input> | |
| <input type="checkbox" name="unchecked">Unchecked</input> | |
| <input type="checkbox" name="disabled" disabled="true">Disabled</input> | |
| <input type="checkbox" name="disabled_and_checked" checked="true" disabled="true">Disabled and checked</input> | |
| <input type="submit" name="submit" value="Send"/> | |
| </form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which allows us to do this trick: