Created
April 17, 2009 20:41
-
-
Save ohammersmith/97244 to your computer and use it in GitHub Desktop.
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
| <h1>Custom form demo</h1> | |
| <!-- maybe the real thing --> | |
| <% form_tag(:action => "create") do %> | |
| <% for question in @questions %> | |
| <%= hidden_field_tag "responses[][#{question.id}][type]", question.q_type %> | |
| <% if question.q_type == "checkbox" %> | |
| Checkbox <br/> | |
| <%= h question.question %> <br /> | |
| <% for option in question.options %> | |
| <%= option %> | |
| <%= check_box_tag "responses[][#{question.id}][answers][]", option %> <br /> | |
| <% end %> | |
| <hr/> | |
| <% end -%> | |
| <% if question.q_type == "select" %> | |
| Select <br/> | |
| <%= h question.question %> <br /> | |
| <%= select_tag ("responses[][#{question.id}][answers][]", options_for_select(question.options) ) %> | |
| <hr/> | |
| <% end -%> | |
| <% if question.q_type == "radio" %> | |
| Radio <br/> | |
| <%= h question.question %> <br /> | |
| <% for option in question.options %> | |
| <%= option %> | |
| <%= radio_button_tag "responses[][#{question.id}][answers][]", option %> <br /> | |
| <% end %> | |
| <hr/> | |
| <% end -%> | |
| <% end %> | |
| <%= submit_tag "Post" %> | |
| <% end -%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment